Submission #171015

#TimeUsernameProblemLanguageResultExecution timeMemory
171015div2derCollider (IZhO11_collider)C++14
100 / 100
231 ms3504 KiB
#include <iostream>
#include <climits>
#include <vector>
using namespace std;

const int N = 2e6;
const int INF = INT_MAX;

vector <pair <int, int> >v;

int main () {
	//cerr << "Ready\n";
	string s;
	int n, q;
	cin >> n >> q;
	cin >> s;
	while(q--) {
		char type;
		cin >> type;
		if (type == 'a') {
			int x, y;
			cin >> x >> y;
			#define eb emplace_back
			#define mkp make_pair
			v.eb(mkp(x, y));
		}
		else {
			int pos;
			cin >> pos;
			#define sz(s) (int)(s.size())
			for (int j = sz(v) - 1; j >= 0; -- j) {
				if (v[j].second == pos){
					pos = v[j].first;
					continue;
				}
				if (v[j].second < pos)
					--pos;
				if (v[j].first <= pos)
					++pos;
			}
			--pos;
			cout << s[pos] << '\n';
		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...