結果

問題 No.160 最短経路のうち辞書順最小
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-03-02 00:14:08
言語 Ruby
(3.1.1p18 )
結果
AC  
実行時間 1,813 ms / 5,000 ms
コード長 220 bytes
コンパイル時間 32 ms
使用メモリ 89,524 KB
最終ジャッジ日時 2023-01-14 17:37:14
合計ジャッジ時間 9,155 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 71 ms
13,732 KB
testcase_01 AC 72 ms
13,764 KB
testcase_02 AC 71 ms
13,864 KB
testcase_03 AC 72 ms
13,972 KB
testcase_04 AC 263 ms
27,156 KB
testcase_05 AC 472 ms
40,584 KB
testcase_06 AC 664 ms
53,952 KB
testcase_07 AC 176 ms
21,472 KB
testcase_08 AC 188 ms
22,176 KB
testcase_09 AC 164 ms
20,340 KB
testcase_10 AC 203 ms
23,084 KB
testcase_11 AC 211 ms
23,604 KB
testcase_12 AC 184 ms
21,460 KB
testcase_13 AC 177 ms
21,192 KB
testcase_14 AC 181 ms
21,668 KB
testcase_15 AC 173 ms
20,784 KB
testcase_16 AC 173 ms
20,800 KB
testcase_17 AC 183 ms
21,936 KB
testcase_18 AC 179 ms
21,040 KB
testcase_19 AC 180 ms
21,512 KB
testcase_20 AC 181 ms
21,672 KB
testcase_21 AC 167 ms
20,560 KB
testcase_22 AC 170 ms
20,812 KB
testcase_23 AC 195 ms
22,316 KB
testcase_24 AC 215 ms
23,708 KB
testcase_25 AC 176 ms
21,176 KB
testcase_26 AC 170 ms
20,704 KB
testcase_27 AC 99 ms
15,088 KB
testcase_28 AC 1,813 ms
89,524 KB
testcase_29 AC 92 ms
15,280 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 s,' ';s=o.map{|a,b,c|s!=a||d[a]<c+d[b]?n:b}.min)while s<n
0