結果

問題 No.240 ナイト散歩
ユーザー akko_yukkyakko_yukky
提出日時 2017-05-26 15:40:11
言語 Ruby
(3.2.2)
結果
WA  
実行時間 -
コード長 716 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,940 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2023-10-20 00:13:16
合計ジャッジ時間 4,584 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
16,124 KB
testcase_01 AC 82 ms
16,124 KB
testcase_02 AC 89 ms
16,124 KB
testcase_03 AC 82 ms
16,124 KB
testcase_04 AC 84 ms
16,124 KB
testcase_05 AC 95 ms
16,124 KB
testcase_06 AC 84 ms
16,124 KB
testcase_07 AC 83 ms
16,124 KB
testcase_08 AC 82 ms
16,124 KB
testcase_09 AC 83 ms
16,124 KB
testcase_10 AC 82 ms
16,128 KB
testcase_11 AC 83 ms
16,124 KB
testcase_12 AC 82 ms
16,124 KB
testcase_13 AC 82 ms
16,124 KB
testcase_14 AC 82 ms
16,124 KB
testcase_15 AC 82 ms
16,124 KB
testcase_16 AC 83 ms
16,124 KB
testcase_17 AC 83 ms
16,124 KB
testcase_18 AC 85 ms
16,124 KB
testcase_19 AC 84 ms
16,124 KB
testcase_20 AC 93 ms
16,124 KB
testcase_21 AC 92 ms
16,124 KB
testcase_22 AC 84 ms
16,124 KB
testcase_23 AC 84 ms
16,124 KB
testcase_24 AC 82 ms
16,124 KB
testcase_25 AC 101 ms
16,124 KB
testcase_26 AC 91 ms
16,124 KB
testcase_27 AC 92 ms
16,124 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 82 ms
16,124 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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
0