Advertisement
Rofyda_Elghadban1

Untitled

Sep 11th, 2023
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1.  int n,q;
  2.  cin>>n>>q;
  3.  vector<char>v(2*n);
  4.  cin(v);
  5.  deque<int>d;
  6.  for(int i=0;i<v.size();i++){
  7.   if(v[i]=='L'){
  8.     d.push_front(v[i+1]);
  9.   }else if(v[i]=='R'){
  10.     d.push_back(v[i+1]);
  11.   }
  12.  }
  13.  cout(d);
  14.  map<int,vector<int>>mp;
  15.  for(int i=0;i<d.size();i++){
  16.   mp[d[i]].push_back(i);
  17.  }
  18.  while(q--){
  19.   int num;
  20.   cin>>num;
  21.   for(int j=0;j<mp[num].size();j++){
  22.     if(mp[num][j]<n/2){
  23.       cout<<"Left"<<"\n";
  24.     }else{
  25.       cout<<"Right"<<"\n";
  26.     }
  27.   }cout<<"\n";
  28.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement