#include <bits/stdc++.h>
using namespace std;
int main () {
ios::sync_with_stdio (false);
cin.tie (0); cout.tie (0);
int n, q;
cin >> n >> q;
string s;
cin >> s;
while (q--) {
char op;
cin >> op;
if (op == 'a') {
int x, y;
cin >> x >> y;
x--, y--;
string to_add (1, s[x]);
s.erase (x, 1);
s.insert (y, to_add);
}
else {
int x;
cin >> x; x--;
cout << s[x] << "\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
17 ms |
748 KB |
Output is correct |
4 |
Correct |
240 ms |
2176 KB |
Output is correct |
5 |
Correct |
443 ms |
2184 KB |
Output is correct |
6 |
Correct |
648 ms |
2440 KB |
Output is correct |
7 |
Correct |
716 ms |
2568 KB |
Output is correct |
8 |
Correct |
308 ms |
2440 KB |
Output is correct |
9 |
Correct |
897 ms |
2696 KB |
Output is correct |
10 |
Correct |
603 ms |
2624 KB |
Output is correct |