結果
| 問題 | No.240 ナイト散歩 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-07-31 22:23:20 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 21 ms / 2,000 ms |
| + 72µs | |
| コード長 | 754 bytes |
| 記録 | |
| コンパイル時間 | 56 ms |
| コンパイル使用メモリ | 14,720 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2026-10-28 17:26:09 |
| 合計ジャッジ時間 | 2,643 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 31 |
ソースコード
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')