結果

問題 No.240 ナイト散歩
ユーザー steek79
提出日時 2015-11-11 16:54:23
言語 Python2
(2.7.18)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-07 21:14:40
合計ジャッジ時間 1,605 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

goal = map(int, raw_input().split())
goal = tuple(goal)
moves = [(-2, -1), (-2, 1), (-1, -2), (-1, 2),
         (1, -2), (1, 2), (2, -1), (2, 1) ]

def dfs_maybe((x, y), n):
    if (x, y) == goal:
        return True
    elif n == 3:
        return False

    for i in xrange(8):
        if dfs_maybe((x + moves[i][0], y + moves[i][1]), n+1):
            return True
    return False

print 'YES' if dfs_maybe((0, 0), 0) else 'NO'
0