結果
問題 | No.1812 Uribo Road |
ユーザー | 👑 rin204 |
提出日時 | 2022-01-20 22:36:37 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 828 bytes |
コンパイル時間 | 215 ms |
コンパイル使用メモリ | 82,036 KB |
実行使用メモリ | 87,980 KB |
最終ジャッジ日時 | 2024-05-03 09:25:54 |
合計ジャッジ時間 | 9,586 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
53,472 KB |
testcase_01 | AC | 36 ms
52,812 KB |
testcase_02 | AC | 36 ms
53,616 KB |
testcase_03 | AC | 208 ms
78,708 KB |
testcase_04 | AC | 36 ms
53,396 KB |
testcase_05 | AC | 35 ms
53,080 KB |
testcase_06 | AC | 36 ms
54,456 KB |
testcase_07 | AC | 38 ms
59,496 KB |
testcase_08 | AC | 352 ms
81,368 KB |
testcase_09 | AC | 672 ms
87,980 KB |
testcase_10 | AC | 277 ms
78,724 KB |
testcase_11 | AC | 199 ms
78,112 KB |
testcase_12 | TLE | - |
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 | -- | - |
ソースコード
from heapq import * n, m, k = map(int, input().split()) R = list(map(int, input().split())) R = {r - 1:1 << i for i, r in enumerate(R)} edges = [[] for _ in range(n)] for i in range(m): a, b, c = map(int, input().split()) a -= 1 b -= 1 if i in R: d = R[i] else: d = -1 edges[a].append((b, c, d)) edges[b].append((a, c, d)) inf = 1 << 40 dist = [[inf] * (1 << k) for _ in range(n)] dist[0][0] = 0 hq = [(0, 0, 0)] while hq: d, pos, bit = heappop(hq) if d > dist[pos][bit]: continue for npos, c, dbit in edges[pos]: if dbit == -1: nbit = bit else: nbit = bit | dbit if dist[npos][nbit] > c + d: dist[npos][nbit] = c + d heappush(hq, (c + d, npos, nbit)) print(dist[-1][-1])