結果

問題 No.240 ナイト散歩
コンテスト
ユーザー togatoga
提出日時 2015-09-15 17:59:42
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 25 ms / 2,000 ms
+ 385µs
コード長 511 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 57 ms
コンパイル使用メモリ 15,232 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2026-09-11 17:11:16
合計ジャッジ時間 2,714 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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")
0