結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2022-01-19 19:54:39 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 445 bytes |
コンパイル時間 | 201 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-11-23 13:59:01 |
合計ジャッジ時間 | 2,271 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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')