結果
問題 | No.807 umg tours |
ユーザー | brthyyjp |
提出日時 | 2021-10-06 17:45:31 |
言語 | PyPy3 (7.3.13) |
結果 |
AC
|
実行時間 | 1,382 ms / 4,000 ms |
コード長 | 1,008 bytes |
コンパイル時間 | 281 ms |
コンパイル使用メモリ | 87,052 KB |
実行使用メモリ | 174,564 KB |
最終ジャッジ日時 | 2023-09-30 08:48:31 |
合計ジャッジ時間 | 18,147 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 85 ms
75,812 KB |
testcase_01 | AC | 85 ms
75,704 KB |
testcase_02 | AC | 88 ms
75,572 KB |
testcase_03 | AC | 91 ms
76,272 KB |
testcase_04 | AC | 85 ms
75,568 KB |
testcase_05 | AC | 84 ms
75,816 KB |
testcase_06 | AC | 86 ms
75,512 KB |
testcase_07 | AC | 90 ms
75,816 KB |
testcase_08 | AC | 76 ms
71,164 KB |
testcase_09 | AC | 81 ms
71,452 KB |
testcase_10 | AC | 81 ms
71,112 KB |
testcase_11 | AC | 756 ms
140,880 KB |
testcase_12 | AC | 831 ms
131,068 KB |
testcase_13 | AC | 1,069 ms
151,328 KB |
testcase_14 | AC | 538 ms
108,808 KB |
testcase_15 | AC | 418 ms
103,164 KB |
testcase_16 | AC | 1,086 ms
155,052 KB |
testcase_17 | AC | 1,338 ms
171,804 KB |
testcase_18 | AC | 1,344 ms
171,128 KB |
testcase_19 | AC | 1,275 ms
167,436 KB |
testcase_20 | AC | 671 ms
127,216 KB |
testcase_21 | AC | 698 ms
128,508 KB |
testcase_22 | AC | 355 ms
99,280 KB |
testcase_23 | AC | 314 ms
94,520 KB |
testcase_24 | AC | 582 ms
157,320 KB |
testcase_25 | AC | 1,382 ms
174,564 KB |
ソースコード
import heapq INF = 10**18 def dijkstra(s, edge): n = len(edge) dist = [INF]*n dist[s] = 0 edgelist = [] heapq.heappush(edgelist,(dist[s], s)) while edgelist: minedge = heapq.heappop(edgelist) if dist[minedge[1]] < minedge[0]: continue v = minedge[1] for e in edge[v]: if dist[e[1]] > dist[v]+e[0]: dist[e[1]] = dist[v]+e[0] heapq.heappush(edgelist,(dist[e[1]], e[1])) return dist import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n, m = map(int, input().split()) G = [[] for i in range(2*n)] for i in range(m): a, b,c = map(int, input().split()) a, b = a-1, b-1 G[a].append((c, b)) G[b].append((c, a)) G[a].append((0, b+n)) G[b].append((0, a+n)) G[a+n].append((c, b+n)) G[b+n].append((c, a+n)) for i in range(n): G[i].append((0, i+n)) dist = dijkstra(0, G) for i in range(n): ans = dist[i]+dist[i+n] print(ans)