-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path208A_dubstep.cpp
49 lines (42 loc) · 879 Bytes
/
208A_dubstep.cpp
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
40
41
42
43
44
45
46
47
48
49
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
int32_t main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
std::string mix;
std::cin >> mix;
size_t index = 0;
while (true)
{
index = mix.find("WUB", index);
if (index == std::string::npos) break;
mix.replace(index, 3, " ");
++index;
}
std::string result = "";
std::string current_block = "";
for (auto character : mix)
{
if (isspace(character) && current_block != "")
{
result = result + current_block + " ";
current_block = "";
}
else if (!isspace(character))
{
current_block += character;
}
}
if (current_block != "")
{
result += current_block;
}
if (isspace(result[result.length() - 1]))
{
result.erase(result.length() - 1);
}
std::cout << result << '\n';
return 0;
}