# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
391318 |
2021-04-18T14:31:10 Z |
Hegdahl |
Toll (BOI17_toll) |
C++17 |
|
1265 ms |
6400 KB |
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include <bits/stdc++.h>
#define ar array
using namespace std;
using ll = long long;
const ll INF = 1LL<<60;
const int mxN = 5e4;
ar<ll, 5> g[mxN];
int mnNxt[mxN];
ll ans[mxN+10];
int main() {
ios::sync_with_stdio(0);cin.tie(0);
int k, n, m, q; cin >> k >> n >> m >> q;
cerr << k << '\n';
for (int i = 0; i < n; ++i)
for (int d = 0; d < k; ++d)
g[i][d] = INF;
for (int mm = 0; mm < m; ++mm) {
int i, j, w; cin >> i >> j >> w;
g[i][j%k] = w;
}
for (int i = 0; i < n; ++i)
mnNxt[i] = i/k*k+k;
fill(ans, ans+n+10, INF);
for (int qq = 0; qq < q; ++qq) {
int i, j; cin >> i >> j;
for (int p = j+1; p < n; ++p)
ans[p] = INF;
ans[j] = 0;
for (int p = j-1; p >= i; --p) {
ans[p] = INF;
for (int d = 0; d < k; ++d)
ans[p] = min(ans[mnNxt[p]+d]+g[p][d], ans[p]);
}
if (ans[i] > INF/2) cout << "-1\n";
else cout << ans[i] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
786 ms |
3912 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
412 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
3 ms |
332 KB |
Output is correct |
8 |
Correct |
790 ms |
3788 KB |
Output is correct |
9 |
Correct |
784 ms |
3852 KB |
Output is correct |
10 |
Correct |
771 ms |
3092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
976 ms |
4572 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
28 ms |
468 KB |
Output is correct |
8 |
Correct |
23 ms |
512 KB |
Output is correct |
9 |
Correct |
1164 ms |
3748 KB |
Output is correct |
10 |
Correct |
1265 ms |
5324 KB |
Output is correct |
11 |
Correct |
989 ms |
4628 KB |
Output is correct |
12 |
Correct |
1223 ms |
4148 KB |
Output is correct |
13 |
Correct |
370 ms |
4256 KB |
Output is correct |
14 |
Correct |
253 ms |
3312 KB |
Output is correct |
15 |
Correct |
346 ms |
3020 KB |
Output is correct |
16 |
Correct |
343 ms |
3080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
26 ms |
3552 KB |
Output is correct |
11 |
Correct |
38 ms |
4292 KB |
Output is correct |
12 |
Correct |
51 ms |
4952 KB |
Output is correct |
13 |
Correct |
54 ms |
5204 KB |
Output is correct |
14 |
Correct |
43 ms |
4568 KB |
Output is correct |
15 |
Correct |
30 ms |
3028 KB |
Output is correct |
16 |
Correct |
30 ms |
3032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
26 ms |
3552 KB |
Output is correct |
11 |
Correct |
38 ms |
4292 KB |
Output is correct |
12 |
Correct |
51 ms |
4952 KB |
Output is correct |
13 |
Correct |
54 ms |
5204 KB |
Output is correct |
14 |
Correct |
43 ms |
4568 KB |
Output is correct |
15 |
Correct |
30 ms |
3028 KB |
Output is correct |
16 |
Correct |
30 ms |
3032 KB |
Output is correct |
17 |
Correct |
257 ms |
4436 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
6 ms |
332 KB |
Output is correct |
24 |
Correct |
6 ms |
588 KB |
Output is correct |
25 |
Correct |
10 ms |
460 KB |
Output is correct |
26 |
Correct |
9 ms |
476 KB |
Output is correct |
27 |
Correct |
243 ms |
3700 KB |
Output is correct |
28 |
Correct |
291 ms |
5064 KB |
Output is correct |
29 |
Correct |
288 ms |
5332 KB |
Output is correct |
30 |
Correct |
276 ms |
4716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
786 ms |
3912 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
412 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
3 ms |
332 KB |
Output is correct |
8 |
Correct |
790 ms |
3788 KB |
Output is correct |
9 |
Correct |
784 ms |
3852 KB |
Output is correct |
10 |
Correct |
771 ms |
3092 KB |
Output is correct |
11 |
Correct |
976 ms |
4572 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
28 ms |
468 KB |
Output is correct |
18 |
Correct |
23 ms |
512 KB |
Output is correct |
19 |
Correct |
1164 ms |
3748 KB |
Output is correct |
20 |
Correct |
1265 ms |
5324 KB |
Output is correct |
21 |
Correct |
989 ms |
4628 KB |
Output is correct |
22 |
Correct |
1223 ms |
4148 KB |
Output is correct |
23 |
Correct |
370 ms |
4256 KB |
Output is correct |
24 |
Correct |
253 ms |
3312 KB |
Output is correct |
25 |
Correct |
346 ms |
3020 KB |
Output is correct |
26 |
Correct |
343 ms |
3080 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
2 ms |
332 KB |
Output is correct |
34 |
Correct |
2 ms |
332 KB |
Output is correct |
35 |
Correct |
2 ms |
332 KB |
Output is correct |
36 |
Correct |
26 ms |
3552 KB |
Output is correct |
37 |
Correct |
38 ms |
4292 KB |
Output is correct |
38 |
Correct |
51 ms |
4952 KB |
Output is correct |
39 |
Correct |
54 ms |
5204 KB |
Output is correct |
40 |
Correct |
43 ms |
4568 KB |
Output is correct |
41 |
Correct |
30 ms |
3028 KB |
Output is correct |
42 |
Correct |
30 ms |
3032 KB |
Output is correct |
43 |
Correct |
257 ms |
4436 KB |
Output is correct |
44 |
Correct |
1 ms |
332 KB |
Output is correct |
45 |
Correct |
1 ms |
332 KB |
Output is correct |
46 |
Correct |
1 ms |
332 KB |
Output is correct |
47 |
Correct |
1 ms |
332 KB |
Output is correct |
48 |
Correct |
1 ms |
332 KB |
Output is correct |
49 |
Correct |
6 ms |
332 KB |
Output is correct |
50 |
Correct |
6 ms |
588 KB |
Output is correct |
51 |
Correct |
10 ms |
460 KB |
Output is correct |
52 |
Correct |
9 ms |
476 KB |
Output is correct |
53 |
Correct |
243 ms |
3700 KB |
Output is correct |
54 |
Correct |
291 ms |
5064 KB |
Output is correct |
55 |
Correct |
288 ms |
5332 KB |
Output is correct |
56 |
Correct |
276 ms |
4716 KB |
Output is correct |
57 |
Correct |
1076 ms |
6400 KB |
Output is correct |
58 |
Correct |
770 ms |
3780 KB |
Output is correct |
59 |
Correct |
681 ms |
4656 KB |
Output is correct |