結果

問題 No.160 最短経路のうち辞書順最小
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-03-01 23:55:12
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,511 ms / 5,000 ms
コード長 331 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 11,296 KB
実行使用メモリ 16,644 KB
最終ジャッジ日時 2023-09-06 06:03:59
合計ジャッジ時間 41,322 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,272 KB
testcase_01 AC 80 ms
15,032 KB
testcase_02 AC 81 ms
15,132 KB
testcase_03 AC 80 ms
15,160 KB
testcase_04 AC 1,469 ms
16,276 KB
testcase_05 AC 1,464 ms
16,536 KB
testcase_06 AC 1,468 ms
16,412 KB
testcase_07 AC 1,447 ms
16,484 KB
testcase_08 AC 1,449 ms
16,384 KB
testcase_09 AC 1,490 ms
16,408 KB
testcase_10 AC 1,511 ms
16,488 KB
testcase_11 AC 1,454 ms
16,408 KB
testcase_12 AC 1,446 ms
16,376 KB
testcase_13 AC 1,477 ms
16,404 KB
testcase_14 AC 1,472 ms
16,356 KB
testcase_15 AC 1,452 ms
16,408 KB
testcase_16 AC 1,464 ms
16,536 KB
testcase_17 AC 1,451 ms
16,360 KB
testcase_18 AC 1,456 ms
16,388 KB
testcase_19 AC 1,450 ms
16,416 KB
testcase_20 AC 1,459 ms
16,604 KB
testcase_21 AC 1,461 ms
16,264 KB
testcase_22 AC 1,480 ms
16,644 KB
testcase_23 AC 1,459 ms
16,564 KB
testcase_24 AC 1,492 ms
16,392 KB
testcase_25 AC 1,449 ms
16,392 KB
testcase_26 AC 1,448 ms
16,544 KB
testcase_27 AC 1,445 ms
16,092 KB
testcase_28 AC 1,484 ms
16,576 KB
testcase_29 AC 1,449 ms
16,136 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,m,s,t=gets.split.map &:to_i
z=10**9
d=(1..n).map{[z]*n}
e=(1..n).map{[z]*n}
m.times{
  u,v,c=gets.split.map &:to_i
  d[u][v]=d[v][u]=e[u][v]=e[v][u]=c
}
n.times{|w|n.times{|u|n.times{|v|
  d[u][u]=0
  d[u][v]=[d[u][v],d[u][w]+d[w][v]].min
}}}
print u=s
(
  print' ',u=(0...n).find{|v|
    d[u][t]==e[u][v]+d[v][t]
  }
)while u!=t
0