結果

問題 No.1473 おでぶなおばけさん
ユーザー 小野寺健小野寺健
提出日時 2021-10-31 09:57:19
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 583 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 49,180 KB
最終ジャッジ日時 2024-04-17 02:15:17
合計ジャッジ時間 30,307 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
17,536 KB
testcase_01 AC 73 ms
12,032 KB
testcase_02 AC 882 ms
44,800 KB
testcase_03 AC 1,190 ms
43,776 KB
testcase_04 AC 392 ms
27,648 KB
testcase_05 AC 263 ms
20,736 KB
testcase_06 AC 1,398 ms
43,520 KB
testcase_07 AC 612 ms
44,160 KB
testcase_08 AC 588 ms
44,288 KB
testcase_09 AC 568 ms
44,288 KB
testcase_10 AC 707 ms
24,320 KB
testcase_11 AC 801 ms
24,192 KB
testcase_12 AC 813 ms
24,576 KB
testcase_13 AC 442 ms
20,224 KB
testcase_14 AC 315 ms
17,792 KB
testcase_15 AC 566 ms
23,040 KB
testcase_16 AC 726 ms
24,320 KB
testcase_17 AC 109 ms
12,800 KB
testcase_18 AC 142 ms
13,312 KB
testcase_19 AC 785 ms
31,104 KB
testcase_20 AC 963 ms
40,448 KB
testcase_21 AC 820 ms
37,376 KB
testcase_22 AC 466 ms
41,088 KB
testcase_23 AC 423 ms
32,640 KB
testcase_24 AC 407 ms
32,896 KB
testcase_25 AC 445 ms
38,016 KB
testcase_26 AC 481 ms
38,912 KB
testcase_27 AC 211 ms
20,224 KB
testcase_28 AC 639 ms
44,032 KB
testcase_29 AC 852 ms
39,552 KB
testcase_30 AC 1,166 ms
43,904 KB
testcase_31 AC 617 ms
44,928 KB
testcase_32 AC 1,488 ms
45,312 KB
testcase_33 AC 849 ms
40,064 KB
testcase_34 AC 380 ms
27,136 KB
testcase_35 AC 534 ms
27,520 KB
testcase_36 AC 369 ms
28,544 KB
testcase_37 AC 400 ms
31,232 KB
testcase_38 AC 130 ms
15,488 KB
testcase_39 AC 749 ms
24,960 KB
testcase_40 AC 728 ms
24,960 KB
testcase_41 AC 313 ms
24,960 KB
testcase_42 AC 326 ms
25,472 KB
testcase_43 TLE -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, m = gets.split(" ").map{|s| s.to_i}

w = Array.new(n) {Array.new(2, -Float::INFINITY)}
0.upto(n-1) {|i|
	w[i][1] = Float::INFINITY
}
w[0][0] = Float::INFINITY

v = Array.new(n) {Array.new}

m.times {
	s, t, d = gets.split(" ").map{|s| s.to_i}
	v[s-1] << [t-1, d]
	v[t-1] << [s-1, d]
}

que = [[0, Float::INFINITY, 0]]

while que.size > 0 do
	cv, cd, ci = que.shift
	v[cv].each {|nv, nd|
		nd = cd if cd < nd
		if nd > w[nv][0] or (nd == w[nv][0] and ci+1 < w[nv][1]) then
			w[nv] = [nd, ci+1]
			que << [nv, nd, ci+1] if nv != n-1
		end
	}		
end

puts "#{w[n-1][0]} #{w[n-1][1]}"
0