Advertisement
999ms

Untitled

Mar 27th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<ext/rope>
  3. using namespace std;
  4. using namespace __gnu_cxx;
  5.  
  6. int main(){
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. int n,m;
  10. rope<char> v;
  11. cin>>n>>m;
  12. for(int i=0;i<n;i++){
  13. char nxt;
  14. cin>>nxt;
  15. v.push_back(nxt);
  16. }
  17.  
  18. char type;
  19. int l,r;
  20. for(int i=0;i<m;i++){
  21. cin>>type;
  22. if(type=='a'){
  23. cin>>l>>r;
  24. l--,r--;
  25. auto d1 = v.substr(l, 1);
  26. v.erase(l, 1);
  27. auto d2 = v.substr(r, n - r);
  28. v.erase(r, n-r);
  29. v.insert(v.mutable_end(), d1);
  30. v.insert(v.mutable_end(), d2);
  31. } else {
  32. cin>>l;
  33. l--;
  34. cout<<v[l]<<"\n";
  35. }
  36. }
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement