/** @kutbilimone **/
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define int long long
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
string s;
cin >> s;
for(int i = 0, x, y; i < m; i++){
char oper;
cin >> oper >> x;
x--;
if(oper == 'a'){
cin >> y;
y--;
if(y < x){
s = s.substr(0, y) + s[x] + s.substr(y, x-y) + s.substr(x+1);
}else{
s = s.substr(0, x) + s.substr(x+1, y-x) + s[x] + s.substr(y+1);
}
}else cout << s[x] << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
7 ms |
492 KB |
Output is correct |
3 |
Correct |
88 ms |
1304 KB |
Output is correct |
4 |
Correct |
838 ms |
7104 KB |
Output is correct |
5 |
Correct |
1760 ms |
6936 KB |
Output is correct |
6 |
Execution timed out |
2096 ms |
8112 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |