結果
問題 | No.1812 Uribo Road |
ユーザー |
|
提出日時 | 2021-11-15 22:30:11 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,506 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 81,860 KB |
実行使用メモリ | 83,248 KB |
最終ジャッジ日時 | 2024-07-07 09:27:37 |
合計ジャッジ時間 | 6,894 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
52,352 KB |
testcase_01 | AC | 33 ms
52,396 KB |
testcase_02 | AC | 48 ms
64,820 KB |
testcase_03 | TLE | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
ソースコード
#嘘 INF = 10 ** 9 N, M, K = map(int,input().split()) #assert (1 <= N <= 200 and K <= 5 and 1 <= K <= M <= N * (N - 1) // 2) dist = [[0 if i == j else INF for i in range(N)] for j in range(N)] R = list(map(int,input().split())) points = [] nes_cost = 0 check_set = set() for i in range(M): A, B, C = map(int,input().split()) #assert(1 <= C <= 10 ** 4 and 1 <= A <= N and 1 <= B <= N and A != B) #assert((A, B) not in check_set and (B, A) not in check_set) if i + 1 in R: nes_cost += C points.append((A - 1, B - 1)) check_set.add((A, B)) dist[A - 1][B - 1] = C dist[B - 1][A - 1] = C for i in range(N): for j in range(N): for k in range(N): dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) for i in range(N): for j in range(N): for k in range(N): dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) for i in range(N): for j in range(N): for k in range(N): dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) import itertools ans = INF for v in itertools.permutations(points): for i in range(2 ** K): now = 0 now_cost = nes_cost for j in range(K): x, y = v[j] if 1 & (i >> j): now_cost += dist[now][x] now = y else: now_cost += dist[now][y] now = x now_cost += dist[now][N - 1] ans = min(ans, now_cost) print(ans)