#include <bits/stdc++.h>
using namespace std;
const int MN = 2e5+5;
int K,M,N,T[200],A[MN],B[MN],C[MN];
char S[MN];
int main()
{
cin >> K >> M >> S >> N;
for(int i=0; i<N; i++) cin >> A[i] >> B[i] >> C[i];
for(int j=0; j<200; j++) T[j] = j;
for(int i=N-1; i>=0; i--){
for(int j=0; j<K; j++){
if(T[j]<C[i]) continue;
if(T[j]<C[i]+B[i]-A[i]) T[j] = T[j]+A[i]-C[i];
else T[j] = T[j]-B[i]+A[i];
}
}
for(int i=0; i<K; i++) cout << S[T[i]];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
325 ms |
8660 KB |
Output is correct |
10 |
Correct |
322 ms |
8664 KB |
Output is correct |
11 |
Correct |
269 ms |
8568 KB |
Output is correct |
12 |
Correct |
344 ms |
8588 KB |
Output is correct |
13 |
Correct |
300 ms |
8440 KB |
Output is correct |
14 |
Correct |
310 ms |
8312 KB |
Output is correct |
15 |
Correct |
281 ms |
8312 KB |
Output is correct |
16 |
Correct |
316 ms |
8464 KB |
Output is correct |
17 |
Correct |
390 ms |
8328 KB |
Output is correct |
18 |
Correct |
304 ms |
8440 KB |
Output is correct |
19 |
Correct |
369 ms |
8508 KB |
Output is correct |
20 |
Correct |
331 ms |
8440 KB |
Output is correct |
21 |
Correct |
317 ms |
8696 KB |
Output is correct |
22 |
Correct |
299 ms |
8552 KB |
Output is correct |
23 |
Correct |
301 ms |
8564 KB |
Output is correct |
24 |
Correct |
317 ms |
8556 KB |
Output is correct |
25 |
Correct |
341 ms |
8664 KB |
Output is correct |
26 |
Correct |
405 ms |
8440 KB |
Output is correct |