# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
976529 | 2024-05-06T16:23:01 Z | phcbaka | Relay Marathon (NOI20_relaymarathon) | C++17 | 155 ms | 12892 KB |
#include <bits/stdc++.h> using namespace std; #define int long long using ii = pair <int, int>; int n, m, k; void read() { cin >> n >> m >> k; } struct vet { int spec[510]={}, a[510][510]; ii dp[510][510]; void calc() { memset(a, 0x3f3f, sizeof(a)); for (int i = 1; i <= n; ++i) a[i][i] = 0; for (int i = 1; i <= m; ++i) { int u, v, L; cin >> u >> v >> L; a[u][v] = min(a[u][v], L); a[v][u] = min(a[v][u], L); } for (int i = 1; i <= k; ++i) { int u; cin >> u; spec[u] = 1; } for (int k = 1; k <= n; ++k) for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) a[i][j] = min(a[i][j], a[i][k]+a[k][j]); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) if (spec[i] == 0 or spec[j] == 0 or i == j) { dp[i][j]={1e9,j}; } else dp[i][j]={a[i][j],j}; sort (dp[i]+1, dp[i]+n+1); } int ans = LLONG_MAX; for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) for (int t = 1; t <= min(5ll, n); ++t) for (int c = 1; c <= min(5ll, n); ++c) if (i != j and i != dp[i][t].second and i != dp[j][c].second and j != dp[i][t].second and j != dp[j][c].second and dp[i][t].second != dp[j][c].second) { ans = min(ans, dp[i][t].first + dp[j][c].first); } cout << ans; exit(0); } }Vetcan; signed main() { cin.tie(0)->sync_with_stdio(0); #define task "cities" if (fopen(task ".inp", "r")) { freopen(task ".inp", "r", stdin); freopen(task ".out", "w", stdout); } read (); // if (n <= 500 and m <= 500) // { Vetcan.calc(); // } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 6492 KB | Output is correct |
2 | Correct | 2 ms | 6492 KB | Output is correct |
3 | Correct | 2 ms | 6492 KB | Output is correct |
4 | Correct | 2 ms | 6488 KB | Output is correct |
5 | Correct | 2 ms | 6492 KB | Output is correct |
6 | Correct | 2 ms | 6492 KB | Output is correct |
7 | Correct | 2 ms | 6536 KB | Output is correct |
8 | Correct | 2 ms | 6492 KB | Output is correct |
9 | Correct | 2 ms | 6492 KB | Output is correct |
10 | Correct | 2 ms | 6492 KB | Output is correct |
11 | Correct | 2 ms | 6492 KB | Output is correct |
12 | Correct | 2 ms | 6492 KB | Output is correct |
13 | Correct | 2 ms | 6492 KB | Output is correct |
14 | Correct | 2 ms | 6492 KB | Output is correct |
15 | Correct | 2 ms | 6488 KB | Output is correct |
16 | Correct | 2 ms | 6488 KB | Output is correct |
17 | Correct | 2 ms | 6488 KB | Output is correct |
18 | Correct | 2 ms | 6492 KB | Output is correct |
19 | Correct | 2 ms | 6492 KB | Output is correct |
20 | Correct | 2 ms | 6492 KB | Output is correct |
21 | Correct | 2 ms | 6492 KB | Output is correct |
22 | Correct | 2 ms | 6492 KB | Output is correct |
23 | Correct | 2 ms | 6492 KB | Output is correct |
24 | Correct | 2 ms | 6492 KB | Output is correct |
25 | Correct | 2 ms | 6488 KB | Output is correct |
26 | Correct | 2 ms | 6492 KB | Output is correct |
27 | Correct | 2 ms | 6492 KB | Output is correct |
28 | Correct | 2 ms | 6488 KB | Output is correct |
29 | Correct | 2 ms | 6492 KB | Output is correct |
30 | Correct | 2 ms | 6492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 6492 KB | Output is correct |
2 | Correct | 2 ms | 6492 KB | Output is correct |
3 | Correct | 2 ms | 6492 KB | Output is correct |
4 | Correct | 2 ms | 6488 KB | Output is correct |
5 | Correct | 2 ms | 6492 KB | Output is correct |
6 | Correct | 2 ms | 6492 KB | Output is correct |
7 | Correct | 2 ms | 6536 KB | Output is correct |
8 | Correct | 2 ms | 6492 KB | Output is correct |
9 | Correct | 2 ms | 6492 KB | Output is correct |
10 | Correct | 2 ms | 6492 KB | Output is correct |
11 | Correct | 2 ms | 6492 KB | Output is correct |
12 | Correct | 2 ms | 6492 KB | Output is correct |
13 | Correct | 2 ms | 6492 KB | Output is correct |
14 | Correct | 2 ms | 6492 KB | Output is correct |
15 | Correct | 2 ms | 6488 KB | Output is correct |
16 | Correct | 2 ms | 6488 KB | Output is correct |
17 | Correct | 2 ms | 6488 KB | Output is correct |
18 | Correct | 2 ms | 6492 KB | Output is correct |
19 | Correct | 2 ms | 6492 KB | Output is correct |
20 | Correct | 2 ms | 6492 KB | Output is correct |
21 | Correct | 2 ms | 6492 KB | Output is correct |
22 | Correct | 2 ms | 6492 KB | Output is correct |
23 | Correct | 2 ms | 6492 KB | Output is correct |
24 | Correct | 2 ms | 6492 KB | Output is correct |
25 | Correct | 2 ms | 6488 KB | Output is correct |
26 | Correct | 2 ms | 6492 KB | Output is correct |
27 | Correct | 2 ms | 6492 KB | Output is correct |
28 | Correct | 2 ms | 6488 KB | Output is correct |
29 | Correct | 2 ms | 6492 KB | Output is correct |
30 | Correct | 2 ms | 6492 KB | Output is correct |
31 | Correct | 131 ms | 6544 KB | Output is correct |
32 | Correct | 129 ms | 6540 KB | Output is correct |
33 | Correct | 125 ms | 6808 KB | Output is correct |
34 | Correct | 128 ms | 6488 KB | Output is correct |
35 | Correct | 128 ms | 6544 KB | Output is correct |
36 | Correct | 139 ms | 6740 KB | Output is correct |
37 | Correct | 136 ms | 6624 KB | Output is correct |
38 | Correct | 130 ms | 6488 KB | Output is correct |
39 | Correct | 141 ms | 7312 KB | Output is correct |
40 | Correct | 140 ms | 6748 KB | Output is correct |
41 | Correct | 130 ms | 6556 KB | Output is correct |
42 | Correct | 137 ms | 6748 KB | Output is correct |
43 | Correct | 137 ms | 6580 KB | Output is correct |
44 | Correct | 128 ms | 6492 KB | Output is correct |
45 | Correct | 128 ms | 6548 KB | Output is correct |
46 | Correct | 153 ms | 7768 KB | Output is correct |
47 | Correct | 134 ms | 6696 KB | Output is correct |
48 | Correct | 140 ms | 7260 KB | Output is correct |
49 | Correct | 145 ms | 7516 KB | Output is correct |
50 | Correct | 132 ms | 6556 KB | Output is correct |
51 | Correct | 134 ms | 6488 KB | Output is correct |
52 | Correct | 128 ms | 6492 KB | Output is correct |
53 | Correct | 136 ms | 7072 KB | Output is correct |
54 | Correct | 147 ms | 7760 KB | Output is correct |
55 | Correct | 131 ms | 6492 KB | Output is correct |
56 | Correct | 130 ms | 6492 KB | Output is correct |
57 | Correct | 129 ms | 6744 KB | Output is correct |
58 | Correct | 155 ms | 8016 KB | Output is correct |
59 | Correct | 128 ms | 6488 KB | Output is correct |
60 | Correct | 136 ms | 6492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 12892 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 6492 KB | Output is correct |
2 | Correct | 2 ms | 6492 KB | Output is correct |
3 | Correct | 2 ms | 6492 KB | Output is correct |
4 | Correct | 2 ms | 6488 KB | Output is correct |
5 | Correct | 2 ms | 6492 KB | Output is correct |
6 | Correct | 2 ms | 6492 KB | Output is correct |
7 | Correct | 2 ms | 6536 KB | Output is correct |
8 | Correct | 2 ms | 6492 KB | Output is correct |
9 | Correct | 2 ms | 6492 KB | Output is correct |
10 | Correct | 2 ms | 6492 KB | Output is correct |
11 | Correct | 2 ms | 6492 KB | Output is correct |
12 | Correct | 2 ms | 6492 KB | Output is correct |
13 | Correct | 2 ms | 6492 KB | Output is correct |
14 | Correct | 2 ms | 6492 KB | Output is correct |
15 | Correct | 2 ms | 6488 KB | Output is correct |
16 | Correct | 2 ms | 6488 KB | Output is correct |
17 | Correct | 2 ms | 6488 KB | Output is correct |
18 | Correct | 2 ms | 6492 KB | Output is correct |
19 | Correct | 2 ms | 6492 KB | Output is correct |
20 | Correct | 2 ms | 6492 KB | Output is correct |
21 | Correct | 2 ms | 6492 KB | Output is correct |
22 | Correct | 2 ms | 6492 KB | Output is correct |
23 | Correct | 2 ms | 6492 KB | Output is correct |
24 | Correct | 2 ms | 6492 KB | Output is correct |
25 | Correct | 2 ms | 6488 KB | Output is correct |
26 | Correct | 2 ms | 6492 KB | Output is correct |
27 | Correct | 2 ms | 6492 KB | Output is correct |
28 | Correct | 2 ms | 6488 KB | Output is correct |
29 | Correct | 2 ms | 6492 KB | Output is correct |
30 | Correct | 2 ms | 6492 KB | Output is correct |
31 | Correct | 131 ms | 6544 KB | Output is correct |
32 | Correct | 129 ms | 6540 KB | Output is correct |
33 | Correct | 125 ms | 6808 KB | Output is correct |
34 | Correct | 128 ms | 6488 KB | Output is correct |
35 | Correct | 128 ms | 6544 KB | Output is correct |
36 | Correct | 139 ms | 6740 KB | Output is correct |
37 | Correct | 136 ms | 6624 KB | Output is correct |
38 | Correct | 130 ms | 6488 KB | Output is correct |
39 | Correct | 141 ms | 7312 KB | Output is correct |
40 | Correct | 140 ms | 6748 KB | Output is correct |
41 | Correct | 130 ms | 6556 KB | Output is correct |
42 | Correct | 137 ms | 6748 KB | Output is correct |
43 | Correct | 137 ms | 6580 KB | Output is correct |
44 | Correct | 128 ms | 6492 KB | Output is correct |
45 | Correct | 128 ms | 6548 KB | Output is correct |
46 | Correct | 153 ms | 7768 KB | Output is correct |
47 | Correct | 134 ms | 6696 KB | Output is correct |
48 | Correct | 140 ms | 7260 KB | Output is correct |
49 | Correct | 145 ms | 7516 KB | Output is correct |
50 | Correct | 132 ms | 6556 KB | Output is correct |
51 | Correct | 134 ms | 6488 KB | Output is correct |
52 | Correct | 128 ms | 6492 KB | Output is correct |
53 | Correct | 136 ms | 7072 KB | Output is correct |
54 | Correct | 147 ms | 7760 KB | Output is correct |
55 | Correct | 131 ms | 6492 KB | Output is correct |
56 | Correct | 130 ms | 6492 KB | Output is correct |
57 | Correct | 129 ms | 6744 KB | Output is correct |
58 | Correct | 155 ms | 8016 KB | Output is correct |
59 | Correct | 128 ms | 6488 KB | Output is correct |
60 | Correct | 136 ms | 6492 KB | Output is correct |
61 | Runtime error | 7 ms | 12892 KB | Execution killed with signal 11 |
62 | Halted | 0 ms | 0 KB | - |