結果

問題 No.240 ナイト散歩
ユーザー H3PO4
提出日時 2020-06-04 16:35:20
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 404 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-29 12:49:32
合計ジャッジ時間 2,680 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

G = tuple(map(int, input().split()))

if G == (0, 0):
    print('YES')
    exit()

st = {(0, 0)}
for _ in range(3):
    new_st = set()
    for x, y in st:
        for dx, dy in ((1, 2), (2, 1), (1, -2), (-2, 1),
                       (-1, 2), (2, -1), (-1, -2), (-2, -1)):
            new_st.add((x + dx, y + dy))
    st = new_st
    if G in st:
        print('YES')
        break
else:
    print('NO')
0