#include <bits/stdc++.h>
#define pb push_back
#define endl "\n"
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define fname ""
#define sz(x) (int)(x.size())
typedef long long ll;
using namespace std;
const ll N = (ll)(5e5) + 322;
const ll INF = (ll)(1e9);
const ll mod = (ll)(1e9) + 7;
const double eps = 1e-9;
string s;
int n, k, x, y, id;
vector <pair <int, int> > v;
char type;
int main () {
ios_base :: sync_with_stdio (false);// cin.tie(0);
// freopen(fname".in", "r", stdin);
// freopen(fname".out", "w", stdout);
cin >> n >> k >> s;
for (int i = 1; i <= k; ++i) {
cin >> type;
if (type == 'a') {
cin >> x >> y;
v.pb(mp(x, y));
}else {
cin >> id;
for (int j = sz(v) - 1; j >= 0; --j) {
if (v[j].se == id) {id = v[j].fi; continue;}
if (v[j].se < id) id--;
if (v[j].fi <= id) id++;
}
cout << s[id - 1] << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1712 KB |
Output is correct |
2 |
Correct |
0 ms |
1844 KB |
Output is correct |
3 |
Correct |
25 ms |
2204 KB |
Output is correct |
4 |
Correct |
0 ms |
4136 KB |
Output is correct |
5 |
Correct |
48 ms |
4136 KB |
Output is correct |
6 |
Correct |
122 ms |
4136 KB |
Output is correct |
7 |
Correct |
115 ms |
4136 KB |
Output is correct |
8 |
Correct |
10 ms |
4136 KB |
Output is correct |
9 |
Correct |
155 ms |
4136 KB |
Output is correct |
10 |
Correct |
79 ms |
4136 KB |
Output is correct |