結果
問題 | No.807 umg tours |
ユーザー | silversmith |
提出日時 | 2019-04-07 13:28:09 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 975 bytes |
コンパイル時間 | 329 ms |
コンパイル使用メモリ | 87,180 KB |
実行使用メモリ | 171,860 KB |
最終ジャッジ日時 | 2023-09-09 07:13:46 |
合計ジャッジ時間 | 15,564 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 93 ms
75,644 KB |
testcase_01 | AC | 96 ms
76,412 KB |
testcase_02 | AC | 104 ms
76,348 KB |
testcase_03 | AC | 99 ms
76,380 KB |
testcase_04 | AC | 93 ms
75,640 KB |
testcase_05 | AC | 95 ms
76,388 KB |
testcase_06 | AC | 103 ms
76,620 KB |
testcase_07 | AC | 97 ms
76,380 KB |
testcase_08 | AC | 84 ms
71,404 KB |
testcase_09 | AC | 83 ms
71,536 KB |
testcase_10 | AC | 84 ms
71,380 KB |
testcase_11 | AC | 854 ms
139,912 KB |
testcase_12 | AC | 806 ms
128,896 KB |
testcase_13 | AC | 1,060 ms
147,648 KB |
testcase_14 | AC | 565 ms
108,636 KB |
testcase_15 | AC | 431 ms
101,444 KB |
testcase_16 | AC | 1,117 ms
152,832 KB |
testcase_17 | AC | 1,413 ms
167,164 KB |
testcase_18 | AC | 1,459 ms
166,508 KB |
testcase_19 | AC | 1,334 ms
161,472 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 650 ms
159,688 KB |
testcase_25 | AC | 1,402 ms
171,860 KB |
ソースコード
import os import sys import fileinput import heapq def main(file): N, M = map(int, file.readline().strip().split(' ')) e=[[] for i in range(2 * 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)) e[v1-1 + N].append((v2-1 + N,cost)) e[v2-1 + N].append((v1-1 + N,cost)) e[v1-1].append((v2-1 + N,0)) e[v2-1].append((v1-1 + N,0)) d = [10**9 + 1] * (2*N) d[0] = 0 d[N] = 0 h = [] heapq.heappush(h, (0,0)) heapq.heappush(h, (0,N)) 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)) print(0) for i in range(1,N): print(d[i] + d[i+N]) if __name__ == "__main__": file = sys.stdin main(file)