結果
問題 |
No.240 ナイト散歩
|
ユーザー |
|
提出日時 | 2019-09-04 22:32:45 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 663 bytes |
コンパイル時間 | 407 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-12-29 22:44:57 |
合計ジャッジ時間 | 2,597 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) ############################## X, Y = map(int, input().split()) def bfs(x, y, X, Y, i): if i == 3+1: return False if x == X and y == Y: return True if bfs(x-2, y-1, X, Y, i+1): return True if bfs(x-2, y+1, X, Y, i+1): return True if bfs(x-1, y-2, X, Y, i+1): return True if bfs(x-1, y+2, X, Y, i+1): return True if bfs(x+1, y-2, X, Y, i+1): return True if bfs(x+1, y+2, X, Y, i+1): return True if bfs(x+2, y-1, X, Y, i+1): return True if bfs(x+2, y+1, X, Y, i+1): return True return False print('YES' if bfs(0,0,X,Y,0) else 'NO')