結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2019-07-31 22:21:10 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 640 bytes |
コンパイル時間 | 82 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-07-05 07:19:09 |
合計ジャッジ時間 | 2,167 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 19 WA * 11 |
ソースコード
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 return False X, Y = map(int, input().split()) if bfs(): print('YES') else: print('NO')