結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2017-08-29 21:38:48 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 898 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2024-11-06 09:45:57 |
合計ジャッジ時間 | 2,763 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
import copydef bfs(x, y):queue = [[0, 0]]cnt = 0while queue:stack = copy.deepcopy(queue)queue.clear()if cnt > 3:return Falsecnt += 1while stack:tmp = stack.pop(0)if tmp[0] == x and tmp[1] == y:return Truequeue = [[tmp[0] - 2, tmp[1] - 1],[tmp[0] - 2, tmp[1] + 1],[tmp[0] - 1, tmp[1] - 2],[tmp[0] - 1, tmp[1] + 2],[tmp[0] + 1, tmp[1] - 2],[tmp[0] + 1, tmp[1] + 2],[tmp[0] + 2, tmp[1] - 1],[tmp[0] + 2, tmp[1] + 1]] + queuereturn Falseif __name__ == '__main__':X, Y = [int(i) for i in input().split()]if bfs(X, Y):print('YES')else:print('NO')