#import <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
inline void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int main() {
fastio();
ll k, m, n;
string s, ans;
cin >> k >> m >> s >> n;
vector<ll> a(n), b(n), c(n);
for (ll i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
for (ll i = 0; i < k; i++) {
ll idx = i;
for (ll j = n - 1; j >= 0; j--) {
if (idx < c[j]) continue;
if (idx < b[j] + c[j] - a[j]) {
idx += a[j] - c[j];
} else {
idx += a[j] - b[j];
}
}
ans += s[idx];
}
cout << ans;
return 0;
}
Compilation message
copypaste2.cpp:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
1 | #import <bits/stdc++.h>
| ^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
171 ms |
10836 KB |
Output is correct |
10 |
Correct |
59 ms |
10836 KB |
Output is correct |
11 |
Correct |
60 ms |
11012 KB |
Output is correct |
12 |
Correct |
185 ms |
10984 KB |
Output is correct |
13 |
Correct |
57 ms |
10704 KB |
Output is correct |
14 |
Correct |
57 ms |
10716 KB |
Output is correct |
15 |
Correct |
56 ms |
10708 KB |
Output is correct |
16 |
Correct |
59 ms |
10844 KB |
Output is correct |
17 |
Correct |
156 ms |
10576 KB |
Output is correct |
18 |
Correct |
46 ms |
10784 KB |
Output is correct |
19 |
Correct |
54 ms |
10896 KB |
Output is correct |
20 |
Correct |
48 ms |
10900 KB |
Output is correct |
21 |
Correct |
55 ms |
11024 KB |
Output is correct |
22 |
Correct |
65 ms |
10836 KB |
Output is correct |
23 |
Correct |
74 ms |
10836 KB |
Output is correct |
24 |
Correct |
105 ms |
11016 KB |
Output is correct |
25 |
Correct |
135 ms |
10944 KB |
Output is correct |
26 |
Correct |
183 ms |
10944 KB |
Output is correct |