/** @BY_KUTBILIM **/
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define ll long long
int main(){
ios_base::sync_with_stdio(false);
cin.tie();
int n, q;
cin >> n >> q;
vector<char> v;
for(int i = 0; i < n; i++){
char c;
cin >> c;
v.pb(c);
}
while(q--){
char type;
cin >> type;
if(type == 'a'){
int i, j;
cin >> i >> j;
i--; j--;
char c = v[i];
v.erase(v.begin() + i, v.begin() + i + 1);
v.insert(v.begin() + j, c);
} else{
int i;
cin >> i;
i--;
cout << v[i] << endl;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
9 ms |
364 KB |
Output is correct |
3 |
Correct |
22 ms |
620 KB |
Output is correct |
4 |
Correct |
256 ms |
1516 KB |
Output is correct |
5 |
Correct |
433 ms |
1516 KB |
Output is correct |
6 |
Correct |
628 ms |
1516 KB |
Output is correct |
7 |
Correct |
712 ms |
1516 KB |
Output is correct |
8 |
Correct |
304 ms |
1644 KB |
Output is correct |
9 |
Correct |
878 ms |
1640 KB |
Output is correct |
10 |
Correct |
598 ms |
1672 KB |
Output is correct |