結果

問題 No.160 最短経路のうち辞書順最小
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-03-02 00:09:07
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,859 ms / 5,000 ms
コード長 228 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 11,536 KB
実行使用メモリ 90,284 KB
最終ジャッジ日時 2023-08-27 05:30:02
合計ジャッジ時間 9,403 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
15,120 KB
testcase_01 AC 80 ms
15,264 KB
testcase_02 AC 81 ms
15,252 KB
testcase_03 AC 83 ms
15,096 KB
testcase_04 AC 279 ms
28,160 KB
testcase_05 AC 478 ms
32,232 KB
testcase_06 AC 667 ms
38,484 KB
testcase_07 AC 186 ms
22,224 KB
testcase_08 AC 199 ms
23,144 KB
testcase_09 AC 171 ms
21,416 KB
testcase_10 AC 215 ms
24,032 KB
testcase_11 AC 218 ms
24,480 KB
testcase_12 AC 191 ms
22,544 KB
testcase_13 AC 184 ms
22,164 KB
testcase_14 AC 189 ms
22,312 KB
testcase_15 AC 180 ms
21,900 KB
testcase_16 AC 182 ms
21,760 KB
testcase_17 AC 193 ms
22,760 KB
testcase_18 AC 186 ms
22,112 KB
testcase_19 AC 188 ms
22,388 KB
testcase_20 AC 194 ms
22,372 KB
testcase_21 AC 178 ms
21,696 KB
testcase_22 AC 182 ms
21,788 KB
testcase_23 AC 205 ms
23,240 KB
testcase_24 AC 224 ms
24,692 KB
testcase_25 AC 185 ms
22,116 KB
testcase_26 AC 182 ms
21,784 KB
testcase_27 AC 112 ms
16,896 KB
testcase_28 AC 1,859 ms
90,284 KB
testcase_29 AC 103 ms
16,440 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,m,s,t=gets.split.map &:to_i
o=[]
m.times{a,b,c=gets.split.map &:to_i;o<<[a,b,c]<<[b,a,c]}
d=[1e9]*n
d[t]=0
n.times{o.map{|a,b,c|x=c+d[b];d[a]>x&&d[a]=x}}
print u=s
(print' ',u=o.map{|a,b,c|u!=a||d[a]<c+d[b]?n:b}.min)while u!=t
0