結果
問題 | No.807 umg tours |
ユーザー | sinsincoscos |
提出日時 | 2019-03-17 13:35:28 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,158 ms / 4,000 ms |
コード長 | 854 bytes |
コンパイル時間 | 367 ms |
コンパイル使用メモリ | 82,372 KB |
実行使用メモリ | 165,888 KB |
最終ジャッジ日時 | 2024-05-02 23:14:37 |
合計ジャッジ時間 | 12,753 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
60,544 KB |
testcase_01 | AC | 46 ms
61,824 KB |
testcase_02 | AC | 46 ms
61,952 KB |
testcase_03 | AC | 46 ms
61,568 KB |
testcase_04 | AC | 44 ms
60,544 KB |
testcase_05 | AC | 43 ms
60,672 KB |
testcase_06 | AC | 45 ms
64,384 KB |
testcase_07 | AC | 42 ms
61,312 KB |
testcase_08 | AC | 32 ms
52,992 KB |
testcase_09 | AC | 35 ms
53,248 KB |
testcase_10 | AC | 36 ms
53,248 KB |
testcase_11 | AC | 650 ms
135,484 KB |
testcase_12 | AC | 631 ms
123,924 KB |
testcase_13 | AC | 829 ms
143,420 KB |
testcase_14 | AC | 412 ms
105,412 KB |
testcase_15 | AC | 309 ms
98,080 KB |
testcase_16 | AC | 851 ms
147,640 KB |
testcase_17 | AC | 1,110 ms
160,780 KB |
testcase_18 | AC | 1,085 ms
160,612 KB |
testcase_19 | AC | 1,030 ms
157,384 KB |
testcase_20 | AC | 579 ms
121,800 KB |
testcase_21 | AC | 595 ms
124,972 KB |
testcase_22 | AC | 277 ms
96,208 KB |
testcase_23 | AC | 254 ms
93,520 KB |
testcase_24 | AC | 492 ms
150,836 KB |
testcase_25 | AC | 1,158 ms
165,888 KB |
ソースコード
from heapq import heappop, heappush import sys input = sys.stdin.readline 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()