結果
問題 | No.807 umg tours |
ユーザー | OKCH3COOH |
提出日時 | 2019-11-13 20:56:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,731 ms / 4,000 ms |
コード長 | 882 bytes |
コンパイル時間 | 488 ms |
コンパイル使用メモリ | 87,024 KB |
実行使用メモリ | 174,256 KB |
最終ジャッジ日時 | 2023-08-15 12:37:36 |
合計ジャッジ時間 | 19,711 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 93 ms
76,020 KB |
testcase_01 | AC | 99 ms
75,980 KB |
testcase_02 | AC | 124 ms
77,548 KB |
testcase_03 | AC | 112 ms
77,444 KB |
testcase_04 | AC | 93 ms
76,084 KB |
testcase_05 | AC | 106 ms
77,468 KB |
testcase_06 | AC | 122 ms
78,212 KB |
testcase_07 | AC | 118 ms
77,492 KB |
testcase_08 | AC | 77 ms
71,560 KB |
testcase_09 | AC | 82 ms
75,816 KB |
testcase_10 | AC | 86 ms
75,852 KB |
testcase_11 | AC | 1,205 ms
154,336 KB |
testcase_12 | AC | 933 ms
131,752 KB |
testcase_13 | AC | 1,334 ms
153,224 KB |
testcase_14 | AC | 670 ms
110,436 KB |
testcase_15 | AC | 535 ms
103,732 KB |
testcase_16 | AC | 1,339 ms
155,512 KB |
testcase_17 | AC | 1,623 ms
173,748 KB |
testcase_18 | AC | 1,731 ms
172,472 KB |
testcase_19 | AC | 1,539 ms
167,200 KB |
testcase_20 | AC | 773 ms
126,244 KB |
testcase_21 | AC | 819 ms
128,408 KB |
testcase_22 | AC | 431 ms
99,656 KB |
testcase_23 | AC | 368 ms
96,364 KB |
testcase_24 | AC | 760 ms
158,080 KB |
testcase_25 | AC | 1,678 ms
174,256 KB |
ソースコード
from heapq import heappush, heappop def sol(): N, M = map(int, input().split()) edges = [[] for _ in range(2 * N)] for _ in range(M): fr, to, cost = map(int, input().split()) fr -= 1 to -= 1 edges[fr].append((to, cost)) edges[to].append((fr, cost)) edges[fr + N].append((to + N, cost)) edges[to + N].append((fr + N, cost)) edges[fr].append((to + N, 0)) edges[to].append((fr + N, 0)) que = [(0, 0)] minDist = [float('inf')] * (2 * N) while que: dist, now = heappop(que) if minDist[now] <= dist: continue minDist[now] = dist for to, cost in edges[now]: d = dist + cost if minDist[to] > d: heappush(que, (d, to)) print(0) for i in range(1, N): print(minDist[i] + minDist[i + N]) sol()