#include <bits/stdc++.h>
using namespace std;
vector <char> ve;
int x, n, m, y;
string st;
char c;
int main (){
cin >> n>> m >> st;
for (int i = 0;i < n;i++){
c = st[i];
ve.push_back(c);
}
while (m--){
cin >> c;
if (c == 'a'){
cin >> x>> y;
c = ve[x - 1];
ve.erase(ve.begin() + x - 1);
ve.insert(ve.begin() + y - 1, c);
}
else{
cin >> x;
cout << ve[x - 1]<<'\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
12 ms |
600 KB |
Output is correct |
3 |
Correct |
26 ms |
1332 KB |
Output is correct |
4 |
Correct |
211 ms |
4188 KB |
Output is correct |
5 |
Correct |
387 ms |
5096 KB |
Output is correct |
6 |
Correct |
520 ms |
6192 KB |
Output is correct |
7 |
Correct |
579 ms |
8076 KB |
Output is correct |
8 |
Correct |
264 ms |
8964 KB |
Output is correct |
9 |
Correct |
738 ms |
10260 KB |
Output is correct |
10 |
Correct |
508 ms |
11604 KB |
Output is correct |