結果
問題 | No.807 umg tours |
ユーザー | silversmith |
提出日時 | 2019-04-07 11:12:31 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,099 bytes |
コンパイル時間 | 839 ms |
コンパイル使用メモリ | 86,684 KB |
実行使用メモリ | 122,440 KB |
最終ジャッジ日時 | 2023-09-09 03:51:37 |
合計ジャッジ時間 | 20,141 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 87 ms
71,604 KB |
testcase_01 | AC | 94 ms
76,204 KB |
testcase_02 | AC | 101 ms
76,168 KB |
testcase_03 | AC | 99 ms
76,240 KB |
testcase_04 | AC | 89 ms
71,352 KB |
testcase_05 | AC | 93 ms
76,112 KB |
testcase_06 | AC | 99 ms
76,084 KB |
testcase_07 | AC | 98 ms
75,852 KB |
testcase_08 | AC | 84 ms
71,608 KB |
testcase_09 | AC | 85 ms
71,344 KB |
testcase_10 | AC | 85 ms
71,312 KB |
testcase_11 | AC | 740 ms
102,652 KB |
testcase_12 | AC | 854 ms
104,964 KB |
testcase_13 | AC | 966 ms
109,980 KB |
testcase_14 | AC | 601 ms
94,972 KB |
testcase_15 | AC | 472 ms
89,476 KB |
testcase_16 | AC | 1,045 ms
112,888 KB |
testcase_17 | AC | 1,178 ms
119,588 KB |
testcase_18 | AC | 1,251 ms
122,440 KB |
testcase_19 | AC | 1,196 ms
118,944 KB |
testcase_20 | TLE | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
import os import sys import fileinput import heapq def main(file): N, M = map(int, file.readline().strip().split(' ')) e=[[] for i in range(N)] for i in range(M): v1, v2, cost = [int(x) for x in file.readline().strip().split(' ')] e[v1-1].append((v2-1,cost)) e[v2-1].append((v1-1,cost)) d = [10**9 + 1] * N d_exe = [10**9 +1] * N d[0] = 0 d_exe[0] = 0 h = [] heapq.heappush(h, (0,0)) while h: c, j = heapq.heappop(h) if d[j]<c: continue for i,cost in e[j]: alt = c + cost if d[i] < alt : continue d[i] = alt heapq.heappush(h,(alt, i)) h = [] heapq.heappush(h, (0,0)) while h: c,j = heapq.heappop(h) if d[j]<c: continue for i, cost in e[j]: alt = c + cost if c + cost < d[j] else d[j] if d_exe[i] < alt : continue d_exe[i] = alt heapq.heappush(h,(alt, i)) for i in range(N): print(d[i] + d_exe[i]) if __name__ == "__main__": file = sys.stdin main(file)