結果

問題 No.240 ナイト散歩
ユーザー けむけむ
提出日時 2021-07-23 02:49:21
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-18 00:07:06
合計ジャッジ時間 1,880 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

def naito(N, loc):
    if N <= 0:
        return
    init_loc = loc
    moves = [[-2, -1], [-2, 1], [-1, -2], [-1, 2], [1, -2], [1, 2], [2, -1], [2, 1]]
    for move in moves:
        loc = [] + init_loc
        loc[0] = loc[0] + move[0]
        loc[1] = loc[1] + move[1]
        if loc == [0, 0]:
            return 'YES'
        next = naito(N - 1, loc)
        if next == 'YES':
            return 'YES'
    return 'NO'

def main():
    X, Y = map(int, input().split())
    loc = [X, Y]
    print(naito(3, loc))

if __name__ == '__main__':
    main()
0