結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
togatoga
|
| 提出日時 | 2015-09-15 17:59:42 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 511 bytes |
| コンパイル時間 | 140 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-10-07 21:10:31 |
| 合計ジャッジ時間 | 2,453 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
from queue import Queue
X,Y = map(int, input().split())
dx = [-2, -2, -1, -1, 1, 1, 2, 2]
dy = [-1, 1, -2, 2, -2, 2, -1, 1]
que = Queue()
que.put((0, 0, 0))
import sys
while (not que.empty()):
pos = que.get()
if (int(pos[0]) == X and int(pos[1]) == Y):
print ("YES")
sys.exit(0)
break
if (int(pos[2]) > 2):
continue
for k in range(len(dx)):
ny = pos[0] + dy[k]
nx = pos[1] + dx[k]
que.put((ny, nx, int(pos[2]) + 1))
print ("NO")
togatoga