#include <bits/stdc++.h>
using namespace std;
int A[200005];
int B[200005];
int C[200005];
signed main() {
cin.sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int K, M;
cin >> K >> M;
string s;
cin >> s;
int N;
cin >> N;
int i, j;
for(i=0;i<N;i++) cin >> A[i] >> B[i] >> C[i];
for(i=0;i<K;i++) {
int pt = i;
for(j=N-1;j>=0;j--) {
if(C[j] <= pt) {
int len = B[j] - A[j];
if(pt >= C[j] + len) {
pt -= len;
}
else {
pt += A[j] - C[j];
}
}
}
//cout << pt << ' ';
cout << s[pt];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
1 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 |
173 ms |
2740 KB |
Output is correct |
10 |
Correct |
79 ms |
2740 KB |
Output is correct |
11 |
Correct |
78 ms |
2860 KB |
Output is correct |
12 |
Correct |
185 ms |
2808 KB |
Output is correct |
13 |
Correct |
77 ms |
3060 KB |
Output is correct |
14 |
Correct |
77 ms |
3016 KB |
Output is correct |
15 |
Correct |
77 ms |
2992 KB |
Output is correct |
16 |
Correct |
77 ms |
3060 KB |
Output is correct |
17 |
Correct |
190 ms |
2900 KB |
Output is correct |
18 |
Correct |
53 ms |
2684 KB |
Output is correct |
19 |
Correct |
53 ms |
2756 KB |
Output is correct |
20 |
Correct |
54 ms |
2756 KB |
Output is correct |
21 |
Correct |
63 ms |
2716 KB |
Output is correct |
22 |
Correct |
73 ms |
2780 KB |
Output is correct |
23 |
Correct |
78 ms |
2804 KB |
Output is correct |
24 |
Correct |
91 ms |
2720 KB |
Output is correct |
25 |
Correct |
138 ms |
2736 KB |
Output is correct |
26 |
Correct |
179 ms |
2724 KB |
Output is correct |