Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstdio>
- #include <cmath>
- #include<algorithm>
- #define FOR(i,l,r) for (int i=l;i<r;i++)
- #define FORx(i,l,r,x) for (int i=l;i<r;i+=x)
- #define FORD(i,r,l) for (int i=r;i>=l;i--)
- #define FORDx(i,r,l,x) for (int i=r;i>=l;i-=x)
- #define EL '\n'
- using namespace std;
- #define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);
- int main() {
- fastio;
- string x;
- cin>>x;
- string tmp;
- int len=x.length();
- for(int i=0;i<len;i++){
- if(x[i]!='R'){
- if(tmp.back()==x[i]){
- tmp.pop_back();
- }
- else{
- tmp.push_back(x[i]);
- }
- }
- else if(x[i]=='R'){
- if(!tmp.empty())reverse(tmp.begin(),tmp.end());
- }
- }
- cout<<tmp<<EL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement