# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
896717 | 2024-01-02T01:06:03 Z | Isam | Autobus (COCI22_autobus) | C++17 | 864 ms | 9556 KB |
#include<bits/stdc++.h> using namespace std; constexpr int sz = 1e5 + 53243; constexpr int inf = 1e9 + 7; int n, m, K, Q; int dp[100][100][100]; signed main(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n >> m; for(register int i = 1; i <= 71; ++i){ for(register int j = i; j <= 71; ++j){ for(register int l = 0; l < 75; ++l) dp[i][j][l] = dp[j][i][l] = inf; } } for(register int i = 1; i <= n; ++i) dp[i][i][0] = 0; for(register int i = 1, a, b, t; i <= m; ++i){ cin >> a >> b >> t; dp[a][b][1] = min(dp[a][b][1], t); } cin >> K >> Q; for(register int k = 0; k < min(K+1, 71); ++k){ for(register int i = 1; i <= n; ++i){ for(register int j = 1; j <= n; ++j){ for(register int l = 1; l <= n; ++l){ for(register int r = 0; r <= k / 2; ++r){ if(dp[i][l][r] != inf && dp[l][j][k - r] != inf) dp[i][j][k] = min(dp[i][j][k], dp[i][l][r] + dp[l][j][k - r]); } } } } } int u, v; while(Q--){ cin >> u >> v; int ans = inf; for(register int i = 0; i < min(K + 1, 71); ++i){ ans = min(ans, dp[u][v][i]); } cout << (ans == inf ? -1 : ans) << '\n'; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2904 KB | Output is correct |
2 | Correct | 1 ms | 2908 KB | Output is correct |
3 | Correct | 1 ms | 2908 KB | Output is correct |
4 | Correct | 1 ms | 2908 KB | Output is correct |
5 | Correct | 1 ms | 2908 KB | Output is correct |
6 | Correct | 1 ms | 2908 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2908 KB | Output is correct |
2 | Correct | 3 ms | 2908 KB | Output is correct |
3 | Correct | 4 ms | 2908 KB | Output is correct |
4 | Correct | 3 ms | 2908 KB | Output is correct |
5 | Correct | 4 ms | 2908 KB | Output is correct |
6 | Correct | 8 ms | 2908 KB | Output is correct |
7 | Correct | 6 ms | 2908 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2904 KB | Output is correct |
2 | Correct | 1 ms | 2908 KB | Output is correct |
3 | Correct | 1 ms | 2908 KB | Output is correct |
4 | Correct | 1 ms | 2908 KB | Output is correct |
5 | Correct | 1 ms | 2908 KB | Output is correct |
6 | Correct | 1 ms | 2908 KB | Output is correct |
7 | Correct | 84 ms | 3088 KB | Output is correct |
8 | Correct | 617 ms | 3108 KB | Output is correct |
9 | Correct | 5 ms | 2908 KB | Output is correct |
10 | Correct | 183 ms | 2908 KB | Output is correct |
11 | Correct | 17 ms | 2908 KB | Output is correct |
12 | Correct | 306 ms | 3092 KB | Output is correct |
13 | Correct | 76 ms | 2904 KB | Output is correct |
14 | Correct | 85 ms | 3092 KB | Output is correct |
15 | Correct | 498 ms | 3092 KB | Output is correct |
16 | Correct | 133 ms | 3088 KB | Output is correct |
17 | Correct | 73 ms | 3104 KB | Output is correct |
18 | Correct | 72 ms | 2908 KB | Output is correct |
19 | Correct | 673 ms | 2904 KB | Output is correct |
20 | Correct | 257 ms | 2904 KB | Output is correct |
21 | Correct | 73 ms | 3108 KB | Output is correct |
22 | Correct | 92 ms | 3092 KB | Output is correct |
23 | Correct | 104 ms | 3112 KB | Output is correct |
24 | Correct | 235 ms | 3088 KB | Output is correct |
25 | Correct | 89 ms | 2908 KB | Output is correct |
26 | Correct | 108 ms | 2908 KB | Output is correct |
27 | Correct | 162 ms | 3152 KB | Output is correct |
28 | Correct | 119 ms | 2904 KB | Output is correct |
29 | Correct | 75 ms | 2988 KB | Output is correct |
30 | Correct | 99 ms | 3112 KB | Output is correct |
31 | Correct | 252 ms | 3092 KB | Output is correct |
32 | Correct | 681 ms | 3100 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2904 KB | Output is correct |
2 | Correct | 1 ms | 2908 KB | Output is correct |
3 | Correct | 1 ms | 2908 KB | Output is correct |
4 | Correct | 1 ms | 2908 KB | Output is correct |
5 | Correct | 1 ms | 2908 KB | Output is correct |
6 | Correct | 1 ms | 2908 KB | Output is correct |
7 | Correct | 2 ms | 2908 KB | Output is correct |
8 | Correct | 3 ms | 2908 KB | Output is correct |
9 | Correct | 4 ms | 2908 KB | Output is correct |
10 | Correct | 3 ms | 2908 KB | Output is correct |
11 | Correct | 4 ms | 2908 KB | Output is correct |
12 | Correct | 8 ms | 2908 KB | Output is correct |
13 | Correct | 6 ms | 2908 KB | Output is correct |
14 | Correct | 84 ms | 3088 KB | Output is correct |
15 | Correct | 617 ms | 3108 KB | Output is correct |
16 | Correct | 5 ms | 2908 KB | Output is correct |
17 | Correct | 183 ms | 2908 KB | Output is correct |
18 | Correct | 17 ms | 2908 KB | Output is correct |
19 | Correct | 306 ms | 3092 KB | Output is correct |
20 | Correct | 76 ms | 2904 KB | Output is correct |
21 | Correct | 85 ms | 3092 KB | Output is correct |
22 | Correct | 498 ms | 3092 KB | Output is correct |
23 | Correct | 133 ms | 3088 KB | Output is correct |
24 | Correct | 73 ms | 3104 KB | Output is correct |
25 | Correct | 72 ms | 2908 KB | Output is correct |
26 | Correct | 673 ms | 2904 KB | Output is correct |
27 | Correct | 257 ms | 2904 KB | Output is correct |
28 | Correct | 73 ms | 3108 KB | Output is correct |
29 | Correct | 92 ms | 3092 KB | Output is correct |
30 | Correct | 104 ms | 3112 KB | Output is correct |
31 | Correct | 235 ms | 3088 KB | Output is correct |
32 | Correct | 89 ms | 2908 KB | Output is correct |
33 | Correct | 108 ms | 2908 KB | Output is correct |
34 | Correct | 162 ms | 3152 KB | Output is correct |
35 | Correct | 119 ms | 2904 KB | Output is correct |
36 | Correct | 75 ms | 2988 KB | Output is correct |
37 | Correct | 99 ms | 3112 KB | Output is correct |
38 | Correct | 252 ms | 3092 KB | Output is correct |
39 | Correct | 681 ms | 3100 KB | Output is correct |
40 | Correct | 50 ms | 3096 KB | Output is correct |
41 | Correct | 615 ms | 3088 KB | Output is correct |
42 | Correct | 12 ms | 3164 KB | Output is correct |
43 | Correct | 680 ms | 3136 KB | Output is correct |
44 | Correct | 20 ms | 3164 KB | Output is correct |
45 | Correct | 659 ms | 3172 KB | Output is correct |
46 | Correct | 76 ms | 9112 KB | Output is correct |
47 | Correct | 362 ms | 9556 KB | Output is correct |
48 | Correct | 112 ms | 9104 KB | Output is correct |
49 | Correct | 684 ms | 9248 KB | Output is correct |
50 | Correct | 76 ms | 9228 KB | Output is correct |
51 | Correct | 124 ms | 9300 KB | Output is correct |
52 | Correct | 81 ms | 9356 KB | Output is correct |
53 | Correct | 640 ms | 9228 KB | Output is correct |
54 | Correct | 83 ms | 9300 KB | Output is correct |
55 | Correct | 95 ms | 9228 KB | Output is correct |
56 | Correct | 538 ms | 9356 KB | Output is correct |
57 | Correct | 864 ms | 9352 KB | Output is correct |
58 | Correct | 80 ms | 9228 KB | Output is correct |
59 | Correct | 182 ms | 9232 KB | Output is correct |
60 | Correct | 526 ms | 9448 KB | Output is correct |
61 | Correct | 650 ms | 9440 KB | Output is correct |
62 | Correct | 83 ms | 8976 KB | Output is correct |
63 | Correct | 120 ms | 9108 KB | Output is correct |
64 | Correct | 138 ms | 9040 KB | Output is correct |
65 | Correct | 683 ms | 9044 KB | Output is correct |