結果

問題 No.424 立体迷路
ユーザー mmmpppmmmppp
提出日時 2016-09-28 15:45:08
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 487 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-05-01 06:13:44
合計ジャッジ時間 3,056 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 83 ms
12,416 KB
testcase_10 RE -
testcase_11 AC 82 ms
12,160 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 86 ms
12,416 KB
testcase_19 RE -
testcase_20 AC 83 ms
12,416 KB
testcase_21 WA -
testcase_22 RE -
testcase_23 AC 81 ms
12,288 KB
testcase_24 WA -
testcase_25 AC 80 ms
12,416 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

W,H=gets.split.map &:to_i
Sx,Sy,Gx,Gy=gets.split.map{|i|i.to_i-1}
T=H.times.map{gets.chomp.chars.map &:to_i}

ag=[[Sx,Sy]]

def candidate(x,y,ag)
  h=T[x][y]
  [[-1,0],[1,0],[0,-1],[0,1]].each{|i,j|
    k,l=x+i,y+j
    t=h-T[k][l]
    ag<<[[k,l]]if k>0&&k<W&&l>0&&l<H&&ag&[k,l]==[]&&t.abs<2
    m,n=k+i,l+j
    ag<<[[m,n]]if m>0&&m<W&&n>0&&n<H&&ag&[m,n]==[]&&h==T[m][n]&&t>0
  }
end

$><<(H*W).times{|i|
    break(:YES)if ag&[Gx, Gy]!=[]
    break(:NO)if !(_=ag[i])
    candidate(*_,ag)}
0