結果
問題 |
No.807 umg tours
|
ユーザー |
|
提出日時 | 2022-05-23 21:29:06 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 597 bytes |
コンパイル時間 | 257 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 199,620 KB |
最終ジャッジ日時 | 2024-09-20 13:21:41 |
合計ジャッジ時間 | 7,499 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 TLE * 1 -- * 14 |
ソースコード
import heapq import sys input = sys.stdin.readline n, m = map(int, input().split()) e = [[] for _ in range(n)] for _ in range(m): ai, bi, ci = map(int, input().split()) e[ai-1].append((bi-1, ci)) e[bi-1].append((ai-1, ci)) q = [(0, 0, 0)] cost = [[None, None] for _ in range(n)] cost[0][1] = 0 while q: c, used, x = heapq.heappop(q) if cost[x][used] is not None: continue cost[x][used] = c for y, cn in e[x]: heapq.heappush(q, (c+cn, used, y)) if not used: heapq.heappush(q, (c, 1, y)) for i in range(n): print(sum(cost[i]))