#include <iostream>
#include <vector>
using namespace std;
#define sz(s) (int)(s.size())
#define eb emplace_back
const int N = 2e5 + 5;
void solve() {
int n, m;
cin >> n >> m;
string s;
cin >> s;
s = "#" + s;
while(m--) {
char type;
cin >> type;
if (type == 'a') {
int l, r;
cin >> l >> r;
if (l > r) {
swap(l, r);
char x = s[r];
for (int i = r - 1; i >= l; -- i)
s[i + 1] = s[i];
s[l] = x;
}
else if (l <= r) {
char x = s[l];
for (int i = l + 1; i <= r; ++ i)
s[i - 1] = s[i];
s[r] = x;
}
}
else {
int pos;
cin >> pos;
cout << s[pos] << '\n';
}
}
}
int main () {
cerr << "Ready\n";
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |