結果
問題 | No.1812 Uribo Road |
ユーザー | 👑 tamato |
提出日時 | 2022-01-14 22:02:48 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,610 bytes |
コンパイル時間 | 439 ms |
コンパイル使用メモリ | 87,716 KB |
実行使用メモリ | 844,492 KB |
最終ジャッジ日時 | 2023-08-12 19:40:58 |
合計ジャッジ時間 | 6,235 ms |
ジャッジサーバーID (参考情報) |
judge9 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
71,816 KB |
testcase_01 | AC | 68 ms
71,864 KB |
testcase_02 | AC | 71 ms
71,820 KB |
testcase_03 | AC | 278 ms
90,208 KB |
testcase_04 | AC | 73 ms
71,512 KB |
testcase_05 | AC | 70 ms
71,828 KB |
testcase_06 | AC | 73 ms
71,508 KB |
testcase_07 | AC | 83 ms
76,592 KB |
testcase_08 | AC | 408 ms
96,000 KB |
testcase_09 | AC | 492 ms
108,960 KB |
testcase_10 | AC | 306 ms
93,604 KB |
testcase_11 | AC | 229 ms
85,132 KB |
testcase_12 | MLE | - |
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 | -- | - |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline import heapq def dijkstra(adj, start): # adj: [[to, cost] * vertices], 0th index must be empty inf = 1 << 60 dist = [inf] * len(adj) dist[start] = 0 q = [] heapq.heappush(q, (0, start)) while q: min_dist, v_from = heapq.heappop(q) if min_dist > dist[v_from]: continue v_tos = adj[v_from] for v_to, cost in v_tos: if min_dist + cost < dist[v_to]: dist[v_to] = min_dist + cost heapq.heappush(q, (dist[v_to], v_to)) return dist N, M, K = map(int, input().split()) R = list(map(int, input().split())) idx = {r: i for i, r in enumerate(R)} adj = [[] for _ in range(N * (1 << K) + 1)] for i in range(1, M+1): a, b, c = map(int, input().split()) if i not in idx: for state in range(1 << K): aa = a + state * N bb = b + state * N adj[aa].append((bb, c)) adj[bb].append((aa, c)) else: j = idx[i] for state in range(1 << K): aa = a + state * N bb = b + state * N state_new = state | (1 << j) aaa = a + state_new * N bbb = b + state_new * N adj[aa].append((bbb, c)) adj[bb].append((aaa, c)) dist = dijkstra(adj, 1) print(dist[-1]) if __name__ == '__main__': main()