結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2015-12-30 18:17:53 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 132 ms / 2,000 ms |
コード長 | 944 bytes |
コンパイル時間 | 3,258 ms |
コンパイル使用メモリ | 79,452 KB |
実行使用メモリ | 54,280 KB |
最終ジャッジ日時 | 2024-10-07 21:18:30 |
合計ジャッジ時間 | 8,430 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
enum Step { p1(1, 2), p2(2, 1), p3(2, -1), p4(1, -2), p5(-1, -2), p6(-2, -1), p7(-2, 1), p8(-1, 2); int x, y; Step(int x, int y) { this.x = x; this.y = y; } } public class No_240 { static int decideX; static int decideY; public static void main(String[] args) { java.util.Scanner sc = new java.util.Scanner(System.in); decideX = sc.nextInt(); decideY = sc.nextInt(); String ans = ""; if (Knight(0, 0, 0)) { ans = "YES"; } else { ans = "NO"; } System.out.println(ans); sc.close(); } static boolean Knight(int x, int y, int c) { if (judge(x, y)) { return true; } if (c >= 3) { return false; } for (Step s : Step.values()) { int nextX = x + s.x; int nextY = y + s.y; if (Knight(nextX, nextY, c + 1)) { return true; } } return false; } static boolean judge(int x, int y) { if (decideX == x && decideY == y) { return true; } else { return false; } } }