-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15029.cpp
More file actions
48 lines (43 loc) · 1 KB
/
15029.cpp
File metadata and controls
48 lines (43 loc) · 1 KB
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
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int read(){char c;int num,f=1;while(c=(char)getchar(),!isdigit(c))if(c=='-')f=-1;num=(int)(c-'0');while(c=(char)getchar(),isdigit(c))num=num*10+(int)(c-'0');return num*f;}
string s;
void work()
{
vector<char> a;
for(int i=0;i<(int)s.size();i++)
{
a.push_back(s[i]);
while(a.size()>=2)
{
int len=(int)a.size()-1;
if(a[len]!=a[len-1]) break;
if(a[len]=='O')
{
a.pop_back();
a.pop_back();
}
else
{
a.pop_back();
a.pop_back();
a.push_back('O');
}
}
}
for(int i=0;i<(int)a.size();i++) printf("%c",a[i]);
printf("\n");
return;
}
signed main()
{
int T=1;//read();
for(int Case=1;Case<=T;Case++)
{
//printf("Case #%d: ",Case);
while(cin>>s) work();
}
return 0;
}