# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
791145 | 2023-07-23T13:02:51 Z | Username4132 | Autobus (COCI22_autobus) | C++14 | 124 ms | 7984 KB |
#include<iostream> using namespace std; #define forn(i, n) for(int i=0; i<(int)n; ++i) const int MAXN=72, INF=1000000010; int n, m, k, q, adj[MAXN][MAXN], dis[MAXN][MAXN][MAXN]; int main(){ scanf("%d %d", &n, &m); forn(i, n) forn(j, n) adj[i][j]=INF; forn(i, n) adj[i][i]=0; forn(i, m){ int a, b, t; scanf("%d %d %d", &a, &b, &t); --a, --b; adj[a][b]=min(adj[a][b], t); } scanf("%d %d", &k, &q); k = min(k, n-1); forn(it, k+1) forn(i, n) forn(j, n) dis[it][i][j]=INF; forn(it, k+1) forn(i, n) dis[it][i][i]=0; forn(it, k){ forn(v, n) forn(i, n) forn(j, n){ dis[it+1][v][j]=min(dis[it+1][v][j], dis[it][v][i] + adj[i][j]); } } forn(i, q){ int a, b; scanf("%d %d", &a, &b), --a, --b; int d = dis[k][a][b]; printf("%d\n", d==INF? -1 : d); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
2 | Correct | 2 ms | 452 KB | Output is correct |
3 | Correct | 3 ms | 468 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 3 ms | 340 KB | Output is correct |
6 | Correct | 3 ms | 468 KB | Output is correct |
7 | Correct | 3 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 8 ms | 852 KB | Output is correct |
8 | Correct | 19 ms | 1760 KB | Output is correct |
9 | Correct | 3 ms | 468 KB | Output is correct |
10 | Correct | 11 ms | 1136 KB | Output is correct |
11 | Correct | 5 ms | 596 KB | Output is correct |
12 | Correct | 17 ms | 1236 KB | Output is correct |
13 | Correct | 88 ms | 6436 KB | Output is correct |
14 | Correct | 89 ms | 6560 KB | Output is correct |
15 | Correct | 107 ms | 7588 KB | Output is correct |
16 | Correct | 92 ms | 6820 KB | Output is correct |
17 | Correct | 89 ms | 6572 KB | Output is correct |
18 | Correct | 89 ms | 6564 KB | Output is correct |
19 | Correct | 124 ms | 7936 KB | Output is correct |
20 | Correct | 112 ms | 7204 KB | Output is correct |
21 | Correct | 92 ms | 6564 KB | Output is correct |
22 | Correct | 91 ms | 6816 KB | Output is correct |
23 | Correct | 90 ms | 6820 KB | Output is correct |
24 | Correct | 102 ms | 7336 KB | Output is correct |
25 | Correct | 98 ms | 6692 KB | Output is correct |
26 | Correct | 93 ms | 6948 KB | Output is correct |
27 | Correct | 98 ms | 7072 KB | Output is correct |
28 | Correct | 99 ms | 6948 KB | Output is correct |
29 | Correct | 87 ms | 6476 KB | Output is correct |
30 | Correct | 97 ms | 6692 KB | Output is correct |
31 | Correct | 98 ms | 7076 KB | Output is correct |
32 | Correct | 104 ms | 7728 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 340 KB | Output is correct |
8 | Correct | 2 ms | 452 KB | Output is correct |
9 | Correct | 3 ms | 468 KB | Output is correct |
10 | Correct | 2 ms | 340 KB | Output is correct |
11 | Correct | 3 ms | 340 KB | Output is correct |
12 | Correct | 3 ms | 468 KB | Output is correct |
13 | Correct | 3 ms | 468 KB | Output is correct |
14 | Correct | 8 ms | 852 KB | Output is correct |
15 | Correct | 19 ms | 1760 KB | Output is correct |
16 | Correct | 3 ms | 468 KB | Output is correct |
17 | Correct | 11 ms | 1136 KB | Output is correct |
18 | Correct | 5 ms | 596 KB | Output is correct |
19 | Correct | 17 ms | 1236 KB | Output is correct |
20 | Correct | 88 ms | 6436 KB | Output is correct |
21 | Correct | 89 ms | 6560 KB | Output is correct |
22 | Correct | 107 ms | 7588 KB | Output is correct |
23 | Correct | 92 ms | 6820 KB | Output is correct |
24 | Correct | 89 ms | 6572 KB | Output is correct |
25 | Correct | 89 ms | 6564 KB | Output is correct |
26 | Correct | 124 ms | 7936 KB | Output is correct |
27 | Correct | 112 ms | 7204 KB | Output is correct |
28 | Correct | 92 ms | 6564 KB | Output is correct |
29 | Correct | 91 ms | 6816 KB | Output is correct |
30 | Correct | 90 ms | 6820 KB | Output is correct |
31 | Correct | 102 ms | 7336 KB | Output is correct |
32 | Correct | 98 ms | 6692 KB | Output is correct |
33 | Correct | 93 ms | 6948 KB | Output is correct |
34 | Correct | 98 ms | 7072 KB | Output is correct |
35 | Correct | 99 ms | 6948 KB | Output is correct |
36 | Correct | 87 ms | 6476 KB | Output is correct |
37 | Correct | 97 ms | 6692 KB | Output is correct |
38 | Correct | 98 ms | 7076 KB | Output is correct |
39 | Correct | 104 ms | 7728 KB | Output is correct |
40 | Correct | 7 ms | 724 KB | Output is correct |
41 | Correct | 20 ms | 1748 KB | Output is correct |
42 | Correct | 4 ms | 468 KB | Output is correct |
43 | Correct | 20 ms | 1796 KB | Output is correct |
44 | Correct | 5 ms | 632 KB | Output is correct |
45 | Correct | 21 ms | 1748 KB | Output is correct |
46 | Correct | 102 ms | 6564 KB | Output is correct |
47 | Correct | 95 ms | 7088 KB | Output is correct |
48 | Correct | 90 ms | 6700 KB | Output is correct |
49 | Correct | 108 ms | 7856 KB | Output is correct |
50 | Correct | 88 ms | 6576 KB | Output is correct |
51 | Correct | 100 ms | 6816 KB | Output is correct |
52 | Correct | 92 ms | 6576 KB | Output is correct |
53 | Correct | 107 ms | 7844 KB | Output is correct |
54 | Correct | 88 ms | 6572 KB | Output is correct |
55 | Correct | 93 ms | 6604 KB | Output is correct |
56 | Correct | 117 ms | 7840 KB | Output is correct |
57 | Correct | 109 ms | 7960 KB | Output is correct |
58 | Correct | 94 ms | 6700 KB | Output is correct |
59 | Correct | 98 ms | 7204 KB | Output is correct |
60 | Correct | 105 ms | 7724 KB | Output is correct |
61 | Correct | 108 ms | 7984 KB | Output is correct |
62 | Correct | 87 ms | 6448 KB | Output is correct |
63 | Correct | 91 ms | 6688 KB | Output is correct |
64 | Correct | 96 ms | 6816 KB | Output is correct |
65 | Correct | 106 ms | 7724 KB | Output is correct |