#include <bits/stdc++.h>
#include <ext/rope>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
using namespace __gnu_cxx;
const int nmax = 5e5 + 1;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
crope r = "";
int n; cin >> n;
int m; cin >> m;
for(int i = 1; i <= n; ++i){
char x; cin >> x;
r.pb(x);
}
for(int i = 1; i <= m; i++){
char t; cin >> t;
if(t == 'a'){
int x, y; cin >> x >> y;
char v = r[x - 1];
r.erase(x - 1, 1);
r.insert(y - 1, v);
}
else{
int x; cin >> x;
cout << r[x - 1] << "\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
18 ms |
464 KB |
Output is correct |
3 |
Correct |
29 ms |
3376 KB |
Output is correct |
4 |
Correct |
86 ms |
14864 KB |
Output is correct |
5 |
Correct |
134 ms |
15796 KB |
Output is correct |
6 |
Correct |
178 ms |
17612 KB |
Output is correct |
7 |
Correct |
185 ms |
18736 KB |
Output is correct |
8 |
Correct |
116 ms |
17740 KB |
Output is correct |
9 |
Correct |
250 ms |
19448 KB |
Output is correct |
10 |
Correct |
188 ms |
18428 KB |
Output is correct |