結果
問題 | No.807 umg tours |
ユーザー | Kentarokumura |
提出日時 | 2019-03-22 23:29:38 |
言語 | PyPy3 (7.3.13) |
結果 |
AC
|
実行時間 | 1,348 ms / 4,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 457 ms |
コンパイル使用メモリ | 87,048 KB |
実行使用メモリ | 166,552 KB |
最終ジャッジ日時 | 2023-08-15 12:07:02 |
合計ジャッジ時間 | 16,075 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 83 ms
75,864 KB |
testcase_01 | AC | 84 ms
76,168 KB |
testcase_02 | AC | 88 ms
76,212 KB |
testcase_03 | AC | 85 ms
76,092 KB |
testcase_04 | AC | 88 ms
75,968 KB |
testcase_05 | AC | 83 ms
76,068 KB |
testcase_06 | AC | 87 ms
75,892 KB |
testcase_07 | AC | 84 ms
75,964 KB |
testcase_08 | AC | 75 ms
71,504 KB |
testcase_09 | AC | 76 ms
71,288 KB |
testcase_10 | AC | 76 ms
71,052 KB |
testcase_11 | AC | 844 ms
137,640 KB |
testcase_12 | AC | 820 ms
126,108 KB |
testcase_13 | AC | 1,038 ms
144,460 KB |
testcase_14 | AC | 562 ms
106,624 KB |
testcase_15 | AC | 439 ms
100,600 KB |
testcase_16 | AC | 1,106 ms
148,712 KB |
testcase_17 | AC | 1,348 ms
162,532 KB |
testcase_18 | AC | 1,321 ms
161,724 KB |
testcase_19 | AC | 1,236 ms
158,568 KB |
testcase_20 | AC | 657 ms
120,560 KB |
testcase_21 | AC | 685 ms
121,948 KB |
testcase_22 | AC | 352 ms
96,700 KB |
testcase_23 | AC | 308 ms
92,740 KB |
testcase_24 | AC | 613 ms
151,364 KB |
testcase_25 | AC | 1,333 ms
166,552 KB |
ソースコード
from heapq import heappop,heappush import sys input = sys.stdin.readline N,M=map(int,input().split()) table=[[] for i in range(2*N)] for i in range(M): a,b,c=map(int,input().split()) a,b=a-1,b-1 table[a].append((b,c)) table[b].append((a,c)) table[a].append((N+b,0)) table[b].append((N+a,0)) table[N+a].append((N+b,c)) table[N+b].append((N+a,c)) H=[] cost=[10**16]*(2*N) cost[0]=0 H.append((0,0)) while H: cos,pt=heappop(H) if cost[pt]<cos: continue for y,c in table[pt]: if cost[y]>cost[pt]+c: cost[y]=cost[pt]+c heappush(H,(cost[y],y)) print(0) for i in range(1,N): print(cost[i]+cost[N+i])