Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<ext/rope>
- using namespace std;
- using namespace __gnu_cxx;
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- int n,m;
- rope<char> v;
- cin>>n>>m;
- for(int i=0;i<n;i++){
- char nxt;
- cin>>nxt;
- v.push_back(nxt);
- }
- char type;
- int l,r;
- for(int i=0;i<m;i++){
- cin>>type;
- if(type=='a'){
- cin>>l>>r;
- l--,r--;
- auto d1 = v.substr(l, 1);
- v.erase(l, 1);
- auto d2 = v.substr(r, n - r);
- v.erase(r, n-r);
- v.insert(v.mutable_end(), d1);
- v.insert(v.mutable_end(), d2);
- } else {
- cin>>l;
- l--;
- cout<<v[l]<<"\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement