#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 202020;
int n, m, k, q, a[N], b[N], c[N]; string s;
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> k >> m >> s >> q;
n = s.size();
for (int i = 1; i <= q; i++) {
cin >> a[i] >> b[i] >> c[i];
}
for (int i = 1; i <= k; i++) {
ll p = i;
for (int j = q; j >= 1; j--) {
if (c[j] + 1 <= p && p <= c[j] + b[j] - a[j])
p = a[j] + (p - c[j]);
else if (p > c[j] + b[j] - a[j])
p -= (b[j] - a[j]);
}
cout << s[p - 1];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
215 ms |
2952 KB |
Output is correct |
10 |
Correct |
102 ms |
2820 KB |
Output is correct |
11 |
Correct |
109 ms |
2844 KB |
Output is correct |
12 |
Correct |
243 ms |
2848 KB |
Output is correct |
13 |
Correct |
100 ms |
3012 KB |
Output is correct |
14 |
Correct |
102 ms |
3020 KB |
Output is correct |
15 |
Correct |
133 ms |
3124 KB |
Output is correct |
16 |
Correct |
101 ms |
3024 KB |
Output is correct |
17 |
Correct |
205 ms |
2800 KB |
Output is correct |
18 |
Correct |
57 ms |
2684 KB |
Output is correct |
19 |
Correct |
61 ms |
2740 KB |
Output is correct |
20 |
Correct |
57 ms |
2800 KB |
Output is correct |
21 |
Correct |
82 ms |
2788 KB |
Output is correct |
22 |
Correct |
90 ms |
2784 KB |
Output is correct |
23 |
Correct |
90 ms |
2892 KB |
Output is correct |
24 |
Correct |
113 ms |
2788 KB |
Output is correct |
25 |
Correct |
171 ms |
2812 KB |
Output is correct |
26 |
Correct |
217 ms |
2708 KB |
Output is correct |