結果

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

ソースコード

diff #

def main():
    gx, gy = map(int, input().split())

    def dfs(x, y, n):
        if n > 3:
            return False
        if x == gx and y == gy:
            return True

        dx = [-2, -2, -1, -1, 1, 1, 2, 2]
        dy = [-1, 1, -2, 2, -2, 2, -1, 1]
        return any(dfs(x + dx[i], y + dy[i], n + 1) for i in range(8))

    if dfs(0, 0, 0):
        print("YES")
    else:
        print("NO")


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