結果
問題 | No.807 umg tours |
ユーザー | tempura_pp |
提出日時 | 2019-03-17 01:43:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,245 ms / 4,000 ms |
コード長 | 816 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 87,308 KB |
実行使用メモリ | 170,972 KB |
最終ジャッジ日時 | 2023-08-15 11:46:23 |
合計ジャッジ時間 | 14,761 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
75,888 KB |
testcase_01 | AC | 78 ms
76,052 KB |
testcase_02 | AC | 83 ms
75,792 KB |
testcase_03 | AC | 83 ms
75,788 KB |
testcase_04 | AC | 76 ms
75,860 KB |
testcase_05 | AC | 75 ms
75,628 KB |
testcase_06 | AC | 89 ms
76,628 KB |
testcase_07 | AC | 81 ms
75,836 KB |
testcase_08 | AC | 68 ms
71,300 KB |
testcase_09 | AC | 68 ms
71,580 KB |
testcase_10 | AC | 68 ms
71,272 KB |
testcase_11 | AC | 737 ms
139,752 KB |
testcase_12 | AC | 720 ms
127,616 KB |
testcase_13 | AC | 990 ms
146,328 KB |
testcase_14 | AC | 511 ms
108,524 KB |
testcase_15 | AC | 391 ms
101,432 KB |
testcase_16 | AC | 979 ms
150,728 KB |
testcase_17 | AC | 1,221 ms
164,732 KB |
testcase_18 | AC | 1,212 ms
164,624 KB |
testcase_19 | AC | 1,150 ms
161,272 KB |
testcase_20 | AC | 667 ms
124,404 KB |
testcase_21 | AC | 671 ms
127,868 KB |
testcase_22 | AC | 352 ms
98,872 KB |
testcase_23 | AC | 321 ms
96,300 KB |
testcase_24 | AC | 576 ms
154,172 KB |
testcase_25 | AC | 1,245 ms
170,972 KB |
ソースコード
from heapq import heappop, heappush def solve() : N, M = map(int, input().split()) edge = [[] for i in range(2*N)] for i in range(M): a, b, c = map(int, input().split()) a-=1 b-=1 edge[a].append((c, b)) edge[b].append((c, a)) edge[a+N].append((c, b+N)) edge[b+N].append((c, a+N)) edge[a].append((0, b+N)) edge[b].append((0, a+N)) dist=[float('inf')]*(2*N) dist[0]=dist[N]=0 pq = [] heappush(pq, (0,0)) heappush(pq, (0,N)) while pq: d, cur = heappop(pq) if d > dist[cur]: continue for cost, to in edge[cur]: if dist[to]>d+cost : dist[to]=d+cost heappush(pq, (d+cost,to)) for i in range(N) : print(dist[i]+dist[i+N]) solve()