結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
|
| 提出日時 | 2019-07-31 22:23:20 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 754 bytes |
| コンパイル時間 | 76 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-07-05 07:19:12 |
| 合計ジャッジ時間 | 1,980 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
from collections import deque
def bfs():
if X == 0 and Y == 0:
return True
queue = deque([])
queue.append((0, 0, 0))
while len(queue) > 0:
current_x, current_y, current_depth= queue.popleft()
if current_depth == 3:
continue
for move_x, move_y in [(-2, -1), (-2, 1), (-1, -2), (-1, 2), (1, -2), (1, 2), (2, -1), (2, 1)]:
next_x, next_y = current_x + move_x, current_y + move_y
if X == next_x and Y == next_y:
return True
queue.append((next_x, next_y, current_depth + 1))
return False
X, Y = map(int, input().split())
if bfs():
print('YES')
else:
print('NO')