結果
問題 | No.807 umg tours |
ユーザー | cmy |
提出日時 | 2022-05-23 18:48:46 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 859 bytes |
コンパイル時間 | 1,288 ms |
コンパイル使用メモリ | 81,076 KB |
実行使用メモリ | 141,648 KB |
最終ジャッジ日時 | 2023-10-20 17:42:27 |
合計ジャッジ時間 | 21,669 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
63,932 KB |
testcase_01 | WA | - |
testcase_02 | AC | 84 ms
76,200 KB |
testcase_03 | AC | 70 ms
70,468 KB |
testcase_04 | WA | - |
testcase_05 | AC | 60 ms
66,072 KB |
testcase_06 | AC | 82 ms
73,920 KB |
testcase_07 | AC | 72 ms
70,480 KB |
testcase_08 | AC | 39 ms
53,528 KB |
testcase_09 | AC | 44 ms
59,304 KB |
testcase_10 | AC | 45 ms
61,736 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 676 ms
103,128 KB |
testcase_21 | AC | 682 ms
104,708 KB |
testcase_22 | AC | 348 ms
87,560 KB |
testcase_23 | AC | 299 ms
85,212 KB |
testcase_24 | AC | 797 ms
130,056 KB |
testcase_25 | WA | - |
ソースコード
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)] c1 = [None] * n while q: c, x = heapq.heappop(q) if c1[x] is not None: continue c1[x] = c for y, cn in e[x]: if c1[y] is not None: continue heapq.heappush(q, (c+cn, y)) q = [(0, 0, 0)] c2 = [None] * n while q: c, x, cut = heapq.heappop(q) if c2[x] is not None: continue c2[x] = (c, cut) for y, cn in e[x]: if c2[y] is not None: continue if cn > cut: heapq.heappush(q, (c+cut, y, cn)) else: heapq.heappush(q, (c+cn, y, cut)) for i in range(n): print(c1[i] + c2[i][0])