A. Dubstep
Problem
Vasya在最好的Berland夜总会担任DJ,他经常在表演中使用dubstep音乐。最近,他决定将几首老歌进行dubstep混音。
让我们假设一首歌由一定数量的单词组成。让这首歌的dubstep混音,Vasya插入一定数量的单词“<跨类= >“tex-font-style-tt WUB > < /跨度”之前,这首歌的第一个词(可能是零),最后一个词后(可能是零),和单词之间(任何一对之间至少有一个相邻的字),然后男孩融合在一起的所有的单词,包括“<跨类= >“tex-font-style-tt WUB > < /跨度”,在一个字符串并在俱乐部播放这首歌。
例如,含有“I AM X”字样的歌曲可以转换为“WUBWUBIWUBAMWUBWUBX”,而不能转换为“WUBWUBIAMWUBX”。
最近,Petya听了Vasya的新dubstep曲目,但由于他不喜欢现代音乐,他决定找出Vasya重新混音的最初歌曲是什么。帮助Petya恢复原来的歌曲。
Input
输入由一个非空字符串组成,只能由大写英文字母组成,字符串长度不超过 200 字符。保证在Vasya重新混音之前,其中没有包含子字符串“WUB”的单词;Vasya没有改变词序。它还保证最初的歌曲至少有一个词。
Output
打印Vasya用来制作dubsteb混音的初始歌曲的歌词。单词之间用空格隔开。
Examples
Input
WUBWUBABCWUB
Output
ABC
Input
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB
Output
WE ARE THE CHAMPIONS MY FRIEND
Note
In the first sample: “WUBWUBABCWUB” = “WUB” + “WUB” + “ABC” + “WUB”. That means that the song originally consisted of a single word “ABC”, and all words “WUB” were added by Vasya.
In the second sample Vasya added a single word “WUB” between all neighbouring words, in the beginning and in the end, except for words “ARE” and “THE” — between them Vasya added two “WUB”.
Code
// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//堆/优先队列
// #include <queue>//队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string b="WUB";
vector<string> a;
void solve()
{
string s;
cin>>s;
while(s.find(b)!=-1)
{
ll idx=s.find(b);
if(!idx) s=s.substr(3,s.size()-3);
else
{
a.push_back(s.substr(0,idx));
s=s.substr(idx,s.size()-idx);
}
}
a.push_back(s);
for(auto t:a) cout<<t<<" ";
cout<<endl;
}
int main()
{
ll t=1;
//cin>>t;
while(t--) solve();
return 0;
}