-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDubstep.cpp
More file actions
39 lines (35 loc) · 759 Bytes
/
Copy pathDubstep.cpp
File metadata and controls
39 lines (35 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Dec 10, 2022 06:02:34 PM 208A - Dubstep GNU C++0x Accepted 15 ms 0 KB
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
string s;
cin >> s;
vector<string> words;
size_t start = 0;
while (true)
{
size_t end = s.find("WUB", start);
if (end == string::npos)
{
words.push_back(s.substr(start, end));
break;
}
if (end != start)
{
words.push_back(s.substr(start, end - start));
}
start = end + 3;
}
if (!words.empty())
{
cout << words[0];
}
for (size_t i = 1; i < words.size(); ++i)
{
cout << " " << words[i];
}
cout << endl;
return 0;
}