Advertisement
Rofyda_Elghadban1

Untitled

Sep 9th, 2023
991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. int n,q;
  2.  cin>>n>>q;
  3.  char arr[n][2];
  4.  vector<char>v;
  5.  for(int i=0;i<n;i++){
  6.   for(int j=0;j<=1;j++){
  7.     cin>>arr[i][j];
  8.     v.push_back(arr[i][j]);
  9.   }
  10.  }
  11.  vector<char>l,r,ans;
  12.  for(int i=0;i<v.size();i++){
  13.   if(v[i]=='R'){
  14.     r.push_back(v[i+1]);
  15.   }else if(v[i]=='L'){
  16.     l.push_back(v[i+1]);
  17.   }
  18.  }
  19.  for(int i=0;i<r.size();i++){
  20.   ans.push_back(r[i]);
  21.  }
  22.  for(int i=0;i<l.size();i++){
  23.   ans.push_back(l[i]);
  24.  }
  25.  reverse(all(ans));
  26.  //cout(ans);
  27.  while(q--){
  28.   int num;
  29.   cin>>num;
  30.   if(n%2==0){
  31.     for(int i=0;i<=ans.size()/2;i++){
  32.       if(num==ans[i]){
  33.         cout<<"Left"<<"\n";
  34.       }
  35.     }
  36.     for(int i=(ans.size()/2)+1;i<ans.size();i++){
  37.       if(num==ans[i]){
  38.         cout<<"Right"<<"\n";
  39.       }
  40.     }
  41.   }else{
  42.     for(int i=0;i<=(ans.size()/2)+1;i++){
  43.       if(num==ans[i]){
  44.         cout<<"Left"<<"\n";
  45.       }
  46.     }
  47.     for(int i=(ans.size()/2)+2;i<ans.size();i++){
  48.       if(num==ans[i]){
  49.         cout<<"Right"<<"\n";
  50.       }
  51.     }
  52.   }
  53.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement