結果
問題 | No.807 umg tours |
ユーザー | kohei2019 |
提出日時 | 2022-04-14 00:54:08 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 850 bytes |
コンパイル時間 | 419 ms |
コンパイル使用メモリ | 87,016 KB |
実行使用メモリ | 137,336 KB |
最終ジャッジ日時 | 2023-08-25 17:25:01 |
合計ジャッジ時間 | 25,871 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 95 ms
76,960 KB |
testcase_01 | AC | 98 ms
76,544 KB |
testcase_02 | AC | 100 ms
76,388 KB |
testcase_03 | AC | 97 ms
76,500 KB |
testcase_04 | AC | 93 ms
76,668 KB |
testcase_05 | AC | 88 ms
76,324 KB |
testcase_06 | AC | 96 ms
76,564 KB |
testcase_07 | AC | 92 ms
76,232 KB |
testcase_08 | AC | 76 ms
70,980 KB |
testcase_09 | AC | 79 ms
71,340 KB |
testcase_10 | AC | 79 ms
71,416 KB |
testcase_11 | AC | 1,074 ms
111,216 KB |
testcase_12 | AC | 1,221 ms
113,604 KB |
testcase_13 | AC | 1,496 ms
122,160 KB |
testcase_14 | AC | 790 ms
99,060 KB |
testcase_15 | AC | 520 ms
92,584 KB |
testcase_16 | AC | 1,391 ms
123,412 KB |
testcase_17 | AC | 2,074 ms
137,336 KB |
testcase_18 | AC | 1,997 ms
137,232 KB |
testcase_19 | AC | 1,761 ms
132,028 KB |
testcase_20 | AC | 910 ms
112,324 KB |
testcase_21 | AC | 925 ms
114,688 KB |
testcase_22 | AC | 459 ms
92,492 KB |
testcase_23 | AC | 446 ms
90,528 KB |
testcase_24 | TLE | - |
testcase_25 | -- | - |
ソースコード
import heapq N,M = map(int,input().split()) lsg = [[] for i in range(N)] for i in range(M): a,b,c = map(int,input().split()) a -= 1 b -= 1 lsg[a].append((b,c)) lsg[b].append((a,c)) h = [(0,0,0)] INF = float('INF') cost0 = [INF]*(N) cost1 = [INF]*(N) cost0[0] = 0 cost1[0] = 0 while h: c,n,f = heapq.heappop(h) for nex,cos in lsg[n]: if f == 0: # 使える if cost0[nex] > c + cos: # 使わない cost0[nex] = c + cos heapq.heappush(h, (c+cos,nex,0)) if cost1[nex] > c: # 使う cost1[nex] = c heapq.heappush(h, (c,nex,1)) if f == 1: # 使えない if cost1[nex] > c+ cos: cost1[nex] = c+ cos heapq.heappush(h, (c+ cos,nex,1)) for i in range(N): print(cost0[i]+cost1[i])