Submission #758726

# Submission time Handle Problem Language Result Execution time Memory
758726 2023-06-15T08:09:47 Z boyliguanhan Toll (BOI17_toll) C++17
100 / 100
1687 ms 4856 KB
#include<bits/stdc++.h>
using namespace std;
int k, n, m, o, x, y, z, i, j, cost[50010][5], ans[50010];
int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);
    memset(cost, 63, sizeof cost);
    cin >> k >> n >> m >> o;
    while(m--) {
        cin >> x >> y >> z;
        cost[x][y%k] = z;
    }
    while(o--) {
        cin >> x >> y;
        for(i = x; i <= y; ++i) ans[i] = 1e9; ans[x] = 0;
        for(i = x; i < y/k*k; i++) for(j = 0; j < k; j++)
            ans[i/k*k+k+j] = min(ans[i] + cost[i][j], ans[i/k*k+k+j]);
        cout << (ans[y]==1e9?-1:ans[y]) << '\n';
    }
}

Compilation message

toll.cpp: In function 'int main()':
toll.cpp:15:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   15 |         for(i = x; i <= y; ++i) ans[i] = 1e9; ans[x] = 0;
      |         ^~~
toll.cpp:15:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   15 |         for(i = x; i <= y; ++i) ans[i] = 1e9; ans[x] = 0;
      |                                               ^~~
# Verdict Execution time Memory Grader output
1 Correct 1175 ms 2444 KB Output is correct
2 Correct 1 ms 1304 KB Output is correct
3 Correct 1 ms 1300 KB Output is correct
4 Correct 1 ms 1300 KB Output is correct
5 Correct 4 ms 1236 KB Output is correct
6 Correct 4 ms 1236 KB Output is correct
7 Correct 3 ms 1236 KB Output is correct
8 Correct 1172 ms 2396 KB Output is correct
9 Correct 1162 ms 2384 KB Output is correct
10 Correct 1165 ms 1608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1662 ms 3080 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1300 KB Output is correct
7 Correct 32 ms 1388 KB Output is correct
8 Correct 31 ms 1364 KB Output is correct
9 Correct 1687 ms 2388 KB Output is correct
10 Correct 1631 ms 3740 KB Output is correct
11 Correct 1675 ms 3308 KB Output is correct
12 Correct 1625 ms 2784 KB Output is correct
13 Correct 327 ms 3708 KB Output is correct
14 Correct 303 ms 2840 KB Output is correct
15 Correct 323 ms 2620 KB Output is correct
16 Correct 310 ms 2616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1304 KB Output is correct
5 Correct 1 ms 1352 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1316 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 2 ms 1304 KB Output is correct
10 Correct 22 ms 2260 KB Output is correct
11 Correct 29 ms 2948 KB Output is correct
12 Correct 33 ms 3584 KB Output is correct
13 Correct 38 ms 3836 KB Output is correct
14 Correct 38 ms 3240 KB Output is correct
15 Correct 21 ms 2568 KB Output is correct
16 Correct 20 ms 2556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1304 KB Output is correct
5 Correct 1 ms 1352 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1316 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 2 ms 1304 KB Output is correct
10 Correct 22 ms 2260 KB Output is correct
11 Correct 29 ms 2948 KB Output is correct
12 Correct 33 ms 3584 KB Output is correct
13 Correct 38 ms 3836 KB Output is correct
14 Correct 38 ms 3240 KB Output is correct
15 Correct 21 ms 2568 KB Output is correct
16 Correct 20 ms 2556 KB Output is correct
17 Correct 355 ms 3064 KB Output is correct
18 Correct 1 ms 1236 KB Output is correct
19 Correct 1 ms 1236 KB Output is correct
20 Correct 1 ms 1188 KB Output is correct
21 Correct 1 ms 1236 KB Output is correct
22 Correct 1 ms 1236 KB Output is correct
23 Correct 7 ms 1236 KB Output is correct
24 Correct 8 ms 1364 KB Output is correct
25 Correct 9 ms 1388 KB Output is correct
26 Correct 8 ms 1316 KB Output is correct
27 Correct 357 ms 2388 KB Output is correct
28 Correct 354 ms 3696 KB Output is correct
29 Correct 358 ms 3936 KB Output is correct
30 Correct 352 ms 3324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1175 ms 2444 KB Output is correct
2 Correct 1 ms 1304 KB Output is correct
3 Correct 1 ms 1300 KB Output is correct
4 Correct 1 ms 1300 KB Output is correct
5 Correct 4 ms 1236 KB Output is correct
6 Correct 4 ms 1236 KB Output is correct
7 Correct 3 ms 1236 KB Output is correct
8 Correct 1172 ms 2396 KB Output is correct
9 Correct 1162 ms 2384 KB Output is correct
10 Correct 1165 ms 1608 KB Output is correct
11 Correct 1662 ms 3080 KB Output is correct
12 Correct 1 ms 1236 KB Output is correct
13 Correct 1 ms 1236 KB Output is correct
14 Correct 1 ms 1236 KB Output is correct
15 Correct 1 ms 1236 KB Output is correct
16 Correct 1 ms 1300 KB Output is correct
17 Correct 32 ms 1388 KB Output is correct
18 Correct 31 ms 1364 KB Output is correct
19 Correct 1687 ms 2388 KB Output is correct
20 Correct 1631 ms 3740 KB Output is correct
21 Correct 1675 ms 3308 KB Output is correct
22 Correct 1625 ms 2784 KB Output is correct
23 Correct 327 ms 3708 KB Output is correct
24 Correct 303 ms 2840 KB Output is correct
25 Correct 323 ms 2620 KB Output is correct
26 Correct 310 ms 2616 KB Output is correct
27 Correct 1 ms 1236 KB Output is correct
28 Correct 1 ms 1236 KB Output is correct
29 Correct 1 ms 1236 KB Output is correct
30 Correct 1 ms 1304 KB Output is correct
31 Correct 1 ms 1352 KB Output is correct
32 Correct 1 ms 1236 KB Output is correct
33 Correct 1 ms 1316 KB Output is correct
34 Correct 2 ms 1364 KB Output is correct
35 Correct 2 ms 1304 KB Output is correct
36 Correct 22 ms 2260 KB Output is correct
37 Correct 29 ms 2948 KB Output is correct
38 Correct 33 ms 3584 KB Output is correct
39 Correct 38 ms 3836 KB Output is correct
40 Correct 38 ms 3240 KB Output is correct
41 Correct 21 ms 2568 KB Output is correct
42 Correct 20 ms 2556 KB Output is correct
43 Correct 355 ms 3064 KB Output is correct
44 Correct 1 ms 1236 KB Output is correct
45 Correct 1 ms 1236 KB Output is correct
46 Correct 1 ms 1188 KB Output is correct
47 Correct 1 ms 1236 KB Output is correct
48 Correct 1 ms 1236 KB Output is correct
49 Correct 7 ms 1236 KB Output is correct
50 Correct 8 ms 1364 KB Output is correct
51 Correct 9 ms 1388 KB Output is correct
52 Correct 8 ms 1316 KB Output is correct
53 Correct 357 ms 2388 KB Output is correct
54 Correct 354 ms 3696 KB Output is correct
55 Correct 358 ms 3936 KB Output is correct
56 Correct 352 ms 3324 KB Output is correct
57 Correct 1151 ms 4856 KB Output is correct
58 Correct 1152 ms 2440 KB Output is correct
59 Correct 1156 ms 3276 KB Output is correct