結果
問題 | No.34 砂漠の行商人 |
ユーザー | letrangerjp |
提出日時 | 2017-06-13 22:56:44 |
言語 | Ruby (3.3.0) |
結果 |
AC
|
実行時間 | 473 ms / 5,000 ms |
コード長 | 664 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 11,300 KB |
実行使用メモリ | 16,600 KB |
最終ジャッジ日時 | 2023-09-10 19:28:25 |
合計ジャッジ時間 | 6,210 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 83 ms
15,132 KB |
testcase_01 | AC | 78 ms
15,152 KB |
testcase_02 | AC | 86 ms
15,100 KB |
testcase_03 | AC | 78 ms
15,292 KB |
testcase_04 | AC | 128 ms
15,708 KB |
testcase_05 | AC | 143 ms
15,640 KB |
testcase_06 | AC | 117 ms
15,384 KB |
testcase_07 | AC | 236 ms
15,816 KB |
testcase_08 | AC | 267 ms
15,872 KB |
testcase_09 | AC | 209 ms
15,996 KB |
testcase_10 | AC | 121 ms
15,940 KB |
testcase_11 | AC | 168 ms
16,396 KB |
testcase_12 | AC | 95 ms
15,388 KB |
testcase_13 | AC | 473 ms
16,412 KB |
testcase_14 | AC | 473 ms
16,444 KB |
testcase_15 | AC | 81 ms
15,292 KB |
testcase_16 | AC | 118 ms
15,488 KB |
testcase_17 | AC | 80 ms
15,284 KB |
testcase_18 | AC | 83 ms
15,180 KB |
testcase_19 | AC | 236 ms
16,160 KB |
testcase_20 | AC | 332 ms
16,600 KB |
testcase_21 | AC | 84 ms
15,460 KB |
testcase_22 | AC | 89 ms
15,340 KB |
testcase_23 | AC | 81 ms
15,288 KB |
testcase_24 | AC | 375 ms
16,584 KB |
testcase_25 | AC | 115 ms
15,464 KB |
コンパイルメッセージ
Main.rb:5: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
N, V, SX, SY, GX, GY = gets.split.take(6).map(&:to_i) MAP = N.times.map{ gets.split.take(N).map(&:to_i) } def f(start, last) visited = Hash.new -1 visited[start] = V q = {start=>V} step = 0 while !q.empty? step += 1 qq = {} q.each{|(x, y), hp| [[x+1, y], [x-1, y], [x, y+1], [x, y-1]].each{|a, b| next if !a.between?(0, N-1) next if !b.between?(0, N-1) _hp = hp - MAP[b][a] next if _hp < 1 return step if [a, b] == last if visited[[a,b]] < _hp visited[[a,b]] = _hp qq[[a,b]] = _hp end } } q = qq end -1 end p f([SX-1, SY-1], [GX-1, GY-1])