Problem - 208A - Codeforces を C++ で書いた

[元ネタ]

[コード]

#include <iostream>
#include <vector>
#include <boost/algorithm/string.hpp>

int
main(){
    std::string input = "WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB";
    boost::replace_all(input, "WUB"," ");

    std::vector<std::string> xs;
    boost::split(xs, input, boost::is_space(), boost::algorithm::token_compress_on );

    auto result = boost::join(xs, " ");

    boost::trim(result);
    std::cout << result << std::endl;

    // ワンライナー
    {
        std::string input = "WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB";
        std::vector<std::string> _;
        auto result = boost::trim_copy(
                boost::join(
                    boost::split(
                        _,
                        static_cast<std::string const>(boost::replace_all_copy(input, "WUB", " ")),
                        boost::is_space(),
                        boost::algorithm::token_compress_on
                    ),
                " ")
            );
        std::cout << result << std::endl;
    }

    return 0;
}

元のコードは @MiyakoDev さんのを参照にしてます。
Boost 使ってすらこの有り様なのでもっとサクッとかけるようになってほしい…。