結果

問題 No.160 最短経路のうち辞書順最小
ユーザー gigurururugigurururu
提出日時 2015-03-04 23:21:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 718 ms / 5,000 ms
コード長 388 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 123,892 KB
最終ジャッジ日時 2023-09-06 12:56:44
合計ジャッジ時間 5,934 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,400 KB
testcase_01 AC 77 ms
71,608 KB
testcase_02 AC 77 ms
71,544 KB
testcase_03 AC 77 ms
71,420 KB
testcase_04 AC 120 ms
78,352 KB
testcase_05 AC 133 ms
78,360 KB
testcase_06 AC 146 ms
82,312 KB
testcase_07 AC 147 ms
78,852 KB
testcase_08 AC 145 ms
78,568 KB
testcase_09 AC 135 ms
78,236 KB
testcase_10 AC 147 ms
79,096 KB
testcase_11 AC 143 ms
79,032 KB
testcase_12 AC 143 ms
78,448 KB
testcase_13 AC 149 ms
79,056 KB
testcase_14 AC 132 ms
78,252 KB
testcase_15 AC 139 ms
78,360 KB
testcase_16 AC 136 ms
78,352 KB
testcase_17 AC 149 ms
79,164 KB
testcase_18 AC 139 ms
78,404 KB
testcase_19 AC 143 ms
78,336 KB
testcase_20 AC 138 ms
78,664 KB
testcase_21 AC 147 ms
78,840 KB
testcase_22 AC 142 ms
78,348 KB
testcase_23 AC 138 ms
78,484 KB
testcase_24 AC 148 ms
79,140 KB
testcase_25 AC 138 ms
78,564 KB
testcase_26 AC 143 ms
78,876 KB
testcase_27 AC 96 ms
75,964 KB
testcase_28 AC 718 ms
123,892 KB
testcase_29 AC 81 ms
71,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N,M,S,G=map(int,input().split())
L=[[] for _ in range(N)]
for _ in range(M):
    a,b,c=map(int,input().split())
    L[a].append([b,c])
    L[b].append([a,c])
q=[[0,[S]],[1e9,[]]]
d={}
while True:
    e,n=heapq.heappop(q)
    t=n[-1]
    if t not in d:
        d[t]=True
        if t==G: break
        for j,i in L[t]: heapq.heappush(q,[i+e,n+[j]])
print(" ".join(map(str,n)))
0