結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
|
| 提出日時 | 2022-02-23 23:01:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 2,000 ms |
| コード長 | 617 bytes |
| コンパイル時間 | 160 ms |
| コンパイル使用メモリ | 82,456 KB |
| 実行使用メモリ | 54,656 KB |
| 最終ジャッジ日時 | 2024-07-01 23:27:19 |
| 合計ジャッジ時間 | 2,877 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
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')