結果

問題 No.160 最短経路のうち辞書順最小
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-03-02 00:05:08
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,900 ms / 5,000 ms
コード長 288 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 11,548 KB
実行使用メモリ 90,388 KB
最終ジャッジ日時 2023-09-06 06:05:19
合計ジャッジ時間 9,138 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,088 KB
testcase_01 AC 72 ms
15,048 KB
testcase_02 AC 75 ms
15,084 KB
testcase_03 AC 70 ms
15,292 KB
testcase_04 AC 288 ms
28,196 KB
testcase_05 AC 503 ms
32,492 KB
testcase_06 AC 731 ms
38,740 KB
testcase_07 AC 186 ms
22,200 KB
testcase_08 AC 206 ms
23,192 KB
testcase_09 AC 179 ms
21,408 KB
testcase_10 AC 219 ms
24,092 KB
testcase_11 AC 225 ms
24,556 KB
testcase_12 AC 196 ms
22,544 KB
testcase_13 AC 180 ms
22,036 KB
testcase_14 AC 189 ms
22,396 KB
testcase_15 AC 179 ms
21,784 KB
testcase_16 AC 176 ms
21,788 KB
testcase_17 AC 192 ms
22,624 KB
testcase_18 AC 193 ms
22,300 KB
testcase_19 AC 192 ms
22,300 KB
testcase_20 AC 188 ms
22,360 KB
testcase_21 AC 180 ms
21,560 KB
testcase_22 AC 192 ms
21,880 KB
testcase_23 AC 213 ms
23,508 KB
testcase_24 AC 232 ms
24,628 KB
testcase_25 AC 188 ms
22,264 KB
testcase_26 AC 177 ms
21,836 KB
testcase_27 AC 102 ms
17,152 KB
testcase_28 AC 1,900 ms
90,388 KB
testcase_29 AC 92 ms
16,412 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

z=10**9
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]
  # o+=[[a,b,c],[b,a,c]]
}
d=[z]*n
d[t]=0
n.times{
  o.map{|a,b,c|
    d[a]=[d[a],c+d[b]].min
  }
}
print u=s
(
  print' ',u=o.map{|a,b,c|
    u!=a||d[a]<c+d[b]?n:b
  }.min
)while u!=t
0