# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170685 | div2der | Collider (IZhO11_collider) | C++14 | 2 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |