結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2022-11-02 19:39:52 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 836 bytes |
コンパイル時間 | 121 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-07-17 08:04:58 |
合計ジャッジ時間 | 2,621 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
def calc_knight_destinations(x: int, y: int) -> list[tuple[int, int]]: return [(x-2, y-1), (x-2, y+1), (x-1, y+2), (x+1, y+2), (x+2, y+1), (x+2, y-1), (x+1, y-2), (x-1, y-2)] def main(): X, Y = map(int, input().split()) target = (X, Y) possible_destinations_1 = calc_knight_destinations(0, 0) possible_destinations_2 = [] for current in possible_destinations_1: possible_destinations_2.extend(calc_knight_destinations(*current)) possible_destinations_3 = [] for current in possible_destinations_2: possible_destinations_3.extend(calc_knight_destinations(*current)) if target in possible_destinations_1 or target in possible_destinations_2 or target in possible_destinations_3: print("YES") else: print("NO") if __name__ == "__main__": main()