Submission #1109199

# Submission time Handle Problem Language Result Execution time Memory
1109199 2024-11-06T07:47:53 Z Tsagana Collider (IZhO11_collider) C++14
100 / 100
137 ms 2756 KB
#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
1 Correct 1 ms 336 KB Output is correct
2 Correct 54 ms 664 KB Output is correct
3 Correct 16 ms 600 KB Output is correct
4 Correct 18 ms 2276 KB Output is correct
5 Correct 60 ms 2284 KB Output is correct
6 Correct 87 ms 2524 KB Output is correct
7 Correct 86 ms 2728 KB Output is correct
8 Correct 16 ms 2540 KB Output is correct
9 Correct 137 ms 2756 KB Output is correct
10 Correct 65 ms 2540 KB Output is correct