結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
|
| 提出日時 | 2015-07-10 22:39:40 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 130 ms / 2,000 ms |
| コード長 | 860 bytes |
| コンパイル時間 | 3,180 ms |
| コンパイル使用メモリ | 77,716 KB |
| 実行使用メモリ | 54,580 KB |
| 最終ジャッジ日時 | 2024-10-07 20:50:32 |
| 合計ジャッジ時間 | 8,228 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
import java.util.Scanner;
public class Main_yukicoder240 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
x = sc.nextInt();
y = sc.nextInt();
if (dfs(0, 0, 0)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
sc.close();
}
private static int x;
private static int y;
private static int[] dx = {1, 1, 2, 2, -1, -1, -2, -2};
private static int[] dy = {2, -2, 1, -1, 2, -2, 1, -1};
private static boolean dfs(int xx, int yy, int i) {
if (xx == x && yy == y) {
return true;
}
if (i == 3) {
return false;
}
for (int j = 0; j < dx.length; j++) {
int tmpx = xx + dx[j];
int tmpy = yy + dy[j];
if (dfs(tmpx, tmpy, i + 1)) {
return true;
}
}
return false;
}
}