#include <bits/stdc++.h>
#include <bits/extc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
int main() {
ll N,Q;
cin >> N >> Q;
__gnu_cxx::rope<char> r;
while(N--){
char c;
cin >> c;
r.push_back(c);
}
while(Q--){
char c;
cin >> c;
if(c=='a'){
ll x,y;
cin >> x >> y;
x--,y--;
char v=r[x];
r.erase(x,1);
r.insert(y,v);
}
if(c=='q'){
ll k;
cin >> k;
k--;
cout << r[k] << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
20 ms |
580 KB |
Output is correct |
3 |
Correct |
34 ms |
3416 KB |
Output is correct |
4 |
Correct |
95 ms |
14928 KB |
Output is correct |
5 |
Correct |
134 ms |
15812 KB |
Output is correct |
6 |
Correct |
162 ms |
17476 KB |
Output is correct |
7 |
Correct |
181 ms |
18864 KB |
Output is correct |
8 |
Correct |
110 ms |
17848 KB |
Output is correct |
9 |
Correct |
199 ms |
19464 KB |
Output is correct |
10 |
Correct |
174 ms |
18648 KB |
Output is correct |