結果
問題 |
No.240 ナイト散歩
|
ユーザー |
|
提出日時 | 2022-01-05 21:52:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 448 bytes |
コンパイル時間 | 219 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 55,756 KB |
最終ジャッジ日時 | 2024-11-06 09:13:50 |
合計ジャッジ時間 | 2,913 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
import collections X,Y = map(int,input().split()) st = (0,0) get = set() moveto = [(-2,-1),(-2,+1),(-1,-2),(-1,2),(1,2),(1,-2),(2,-1),(2,1)] d = collections.deque([(0,0,0)]) while d: x,y,c = d.popleft() if (x,y) in get: continue if c == 4: continue get.add((x,y)) for dx,dy in moveto: if (x+dx,y+dy) in get: continue d.append((x+dx,y+dy,c+1)) print('YES' if (X,Y) in get else 'NO')