#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()
{
ios_base::sync_with_stdio(0),cin.tie(0);
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]];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
122 ms |
2680 KB |
Output is correct |
10 |
Correct |
113 ms |
2884 KB |
Output is correct |
11 |
Correct |
114 ms |
2716 KB |
Output is correct |
12 |
Correct |
132 ms |
2680 KB |
Output is correct |
13 |
Correct |
92 ms |
2808 KB |
Output is correct |
14 |
Correct |
108 ms |
2936 KB |
Output is correct |
15 |
Correct |
117 ms |
2936 KB |
Output is correct |
16 |
Correct |
100 ms |
2832 KB |
Output is correct |
17 |
Correct |
165 ms |
2696 KB |
Output is correct |
18 |
Correct |
77 ms |
2680 KB |
Output is correct |
19 |
Correct |
83 ms |
2680 KB |
Output is correct |
20 |
Correct |
74 ms |
2680 KB |
Output is correct |
21 |
Correct |
82 ms |
2688 KB |
Output is correct |
22 |
Correct |
86 ms |
2700 KB |
Output is correct |
23 |
Correct |
92 ms |
2680 KB |
Output is correct |
24 |
Correct |
94 ms |
2680 KB |
Output is correct |
25 |
Correct |
109 ms |
2680 KB |
Output is correct |
26 |
Correct |
121 ms |
2680 KB |
Output is correct |