結果
問題 |
No.240 ナイト散歩
|
ユーザー |
|
提出日時 | 2017-05-26 15:40:11 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 716 bytes |
コンパイル時間 | 140 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-09-19 20:06:56 |
合計ジャッジ時間 | 4,031 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 WA * 5 |
コンパイルメッセージ
Syntax OK
ソースコード
x,y = gets.split.map(&:to_i) if (x.abs >= 7 || y.abs >= 7) then puts "NO" return end q = Array.new() gone = Array.new() xjump=[1,1,-1,-1,2,2,-2,-2] yjump=[2,-2,2,-2,1,-1,1,-1] cp = [0,0] #current_position q.push(cp) gone.push(cp) while q cp = q.shift if cp == [x,y] then puts "YES" return else gone.push(cp) for i in (0..7) np = [ cp[0] + xjump[i] , cp[1] + yjump[i] ] #next_position unless gone.include?(np) then q.push(np) gone.push(np) end end end end