MirzaMdAzwad

Aliens

Aug 4th, 2021
586
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstdio>
  4. #include <cmath>
  5. #include<algorithm>
  6. #define FOR(i,l,r) for (int i=l;i<r;i++)
  7. #define FORx(i,l,r,x) for (int i=l;i<r;i+=x)
  8. #define FORD(i,r,l) for (int i=r;i>=l;i--)
  9. #define FORDx(i,r,l,x) for (int i=r;i>=l;i-=x)
  10. #define EL '\n'
  11. using namespace std;
  12. #define fastio  ios_base::sync_with_stdio(0);cin.tie(NULL);
  13.  
  14. int main() {
  15.     fastio;
  16.     string x;
  17.     cin>>x;
  18.     string tmp;
  19.     int len=x.length();
  20.     for(int i=0;i<len;i++){
  21.         if(x[i]!='R'){
  22.             if(tmp.back()==x[i]){
  23.                 tmp.pop_back();
  24.             }
  25.             else{
  26.                 tmp.push_back(x[i]);
  27.             }
  28.         }
  29.         else if(x[i]=='R'){
  30.             if(!tmp.empty())reverse(tmp.begin(),tmp.end());
  31.         }
  32.     }
  33.     cout<<tmp<<EL;
  34. }
RAW Paste Data