# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1109199 | Tsagana | Collider (IZhO11_collider) | C++14 | 137 ms | 2756 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<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define lnl long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
using namespace std;
void solve () {
int n, q; cin >> n >> q;
string s; cin >> s;
vector<pair<int, int>> v;
while (q--) {
char c; cin >> c;
if (c == 'a') { int l, r; cin >> l >> r; v.pb({l, r});}
else {
int k; cin >> k;
for (int i = v.size()-1; i >= 0; i--) {
if (k == v[i].S) {k = v[i].F; continue ;}
if (v[i].F < v[i].S && k >= v[i].F && k < v[i].S) k++;
if (v[i].F > v[i].S && k <= v[i].F && k > v[i].S) k--;
}
cout << s[k-1] << '\n';
}
}
}
int main() {IOS solve(); return 0;}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |