結果

問題 No.240 ナイト散歩
ユーザー ryusukeryusuke
提出日時 2022-02-23 23:01:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 617 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 71,800 KB
最終ジャッジ日時 2023-09-14 16:20:21
合計ジャッジ時間 5,724 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,676 KB
testcase_01 AC 97 ms
71,448 KB
testcase_02 AC 94 ms
71,556 KB
testcase_03 AC 93 ms
71,504 KB
testcase_04 AC 96 ms
71,660 KB
testcase_05 AC 96 ms
71,796 KB
testcase_06 AC 93 ms
71,644 KB
testcase_07 AC 94 ms
71,480 KB
testcase_08 AC 94 ms
71,564 KB
testcase_09 AC 96 ms
71,640 KB
testcase_10 AC 94 ms
71,472 KB
testcase_11 AC 94 ms
71,692 KB
testcase_12 AC 93 ms
71,556 KB
testcase_13 AC 94 ms
71,656 KB
testcase_14 AC 95 ms
71,584 KB
testcase_15 AC 96 ms
71,772 KB
testcase_16 AC 91 ms
71,784 KB
testcase_17 AC 94 ms
71,444 KB
testcase_18 AC 91 ms
71,800 KB
testcase_19 AC 94 ms
71,628 KB
testcase_20 AC 93 ms
71,784 KB
testcase_21 AC 95 ms
71,616 KB
testcase_22 AC 96 ms
71,680 KB
testcase_23 AC 95 ms
71,300 KB
testcase_24 AC 95 ms
71,596 KB
testcase_25 AC 96 ms
71,588 KB
testcase_26 AC 95 ms
71,584 KB
testcase_27 AC 93 ms
71,760 KB
testcase_28 AC 96 ms
71,684 KB
testcase_29 AC 96 ms
71,604 KB
testcase_30 AC 97 ms
71,640 KB
testcase_31 AC 96 ms
71,720 KB
testcase_32 AC 97 ms
71,696 KB
testcase_33 AC 95 ms
71,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque

X, Y = map(int, input().split())

d = ((-1, -2), (1, -2), (-2, -1), (2, -1), (-2, 1), (2, 1), (-1, 2), (1, 2))

check = defaultdict(int)
check['0_0'] = 1
q = deque()
q.append([0, 0])
for i in range(3):
    q_tmp = deque()
    while q:
        vy, vx = q.popleft()
        for dy, dx in d:
            y = vy + dy
            x = vx + dx
            if check[f'{y}_{x}'] != 0: continue
            check[f'{y}_{x}'] = 1
            q_tmp.append((y, x))
    
    while q_tmp:
        v = q_tmp.popleft()
        q.append(v)

print('YES') if check[f'{Y}_{X}'] else print('NO')
0