#include "bits/stdc++.h"
#include "ext/rope"
#define ll long long
using namespace std;
using namespace __gnu_cxx;
int main() {
int n, m;
cin >> n >> m;
rope<char> rp;
for (int i = 0; i < n; i ++) {
char c; cin >> c;
rp.push_back(c);
}
while (m --) {
char c; cin >> c;
if ('a' == c) {
int a, b; cin >> a >> b;
a --, b --;
char c = rp[a];
rp.erase(rp.mutable_begin() + a);
rp.insert(rp.mutable_begin() + b, c);
} else {
int x; cin >> x;
x --;
cout << rp[x] << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
20 ms |
348 KB |
Output is correct |
3 |
Correct |
30 ms |
3436 KB |
Output is correct |
4 |
Correct |
86 ms |
14932 KB |
Output is correct |
5 |
Correct |
129 ms |
15956 KB |
Output is correct |
6 |
Correct |
146 ms |
17680 KB |
Output is correct |
7 |
Correct |
156 ms |
18768 KB |
Output is correct |
8 |
Correct |
97 ms |
17840 KB |
Output is correct |
9 |
Correct |
177 ms |
19540 KB |
Output is correct |
10 |
Correct |
145 ms |
18464 KB |
Output is correct |