結果
問題 | No.34 砂漠の行商人 |
ユーザー | letrangerjp |
提出日時 | 2017-06-13 21:31:03 |
言語 | Ruby (3.3.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 774 bytes |
コンパイル時間 | 157 ms |
コンパイル使用メモリ | 11,252 KB |
実行使用メモリ | 19,948 KB |
最終ジャッジ日時 | 2023-09-10 19:29:07 |
合計ジャッジ時間 | 24,267 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 84 ms
15,256 KB |
testcase_01 | AC | 85 ms
15,120 KB |
testcase_02 | AC | 93 ms
15,532 KB |
testcase_03 | AC | 85 ms
15,072 KB |
testcase_04 | AC | 183 ms
15,692 KB |
testcase_05 | AC | 296 ms
15,668 KB |
testcase_06 | AC | 107 ms
15,472 KB |
testcase_07 | AC | 477 ms
15,784 KB |
testcase_08 | AC | 756 ms
15,840 KB |
testcase_09 | AC | 1,929 ms
18,312 KB |
testcase_10 | AC | 319 ms
15,860 KB |
testcase_11 | AC | 784 ms
15,980 KB |
testcase_12 | AC | 128 ms
15,616 KB |
testcase_13 | TLE | - |
testcase_14 | AC | 4,480 ms
19,948 KB |
testcase_15 | AC | 89 ms
15,524 KB |
testcase_16 | AC | 330 ms
15,716 KB |
testcase_17 | AC | 87 ms
15,460 KB |
testcase_18 | AC | 103 ms
15,624 KB |
testcase_19 | AC | 1,349 ms
18,740 KB |
testcase_20 | AC | 2,181 ms
19,124 KB |
testcase_21 | AC | 91 ms
15,496 KB |
testcase_22 | AC | 110 ms
15,832 KB |
testcase_23 | AC | 92 ms
15,336 KB |
testcase_24 | AC | 2,788 ms
19,008 KB |
testcase_25 | AC | 247 ms
15,964 KB |
コンパイルメッセージ
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 = N.times.map{[-1]*N} visited[start[0]][start[1]] = V q = [[0, V] + start] res = -1 while !q.empty? step, hp, x, y = q.shift if [x, y] == last res = step break end [[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 _step = step + 1 if visited[a][b] < _hp visited[a][b] = _hp elem = [_step, _hp, a, b] # q[q.bsearch_index{|v|(v <=> elem) < 0}||q.size, 0] = [elem] q << elem end } end res end p f([SX-1, SY-1], [GX-1, GY-1])