結果
| 問題 |
No.240 ナイト散歩
|
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2016-12-12 01:41:44 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 142 ms / 2,000 ms |
| コード長 | 761 bytes |
| コンパイル時間 | 2,202 ms |
| コンパイル使用メモリ | 74,048 KB |
| 実行使用メモリ | 54,392 KB |
| 最終ジャッジ日時 | 2024-10-07 21:33:15 |
| 合計ジャッジ時間 | 8,374 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
import java.util.*;
public class Main {
static int X;
static int Y;
static int [] dx = {-2,-2,-1,-1,1,1,2,2};
static int [] dy = {1,-1,2,-2,2,-2,1,-1};
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
X = sc.nextInt();
Y = sc.nextInt();
if(move(0,0,0)){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
static boolean move(int x, int y, int c){
if(c>3){
return false;
}
if(x==X&&y==Y){
return true;
}
for(int i=0; i<8; i++){
if(move(x+dx[i], y+dy[i], c+1)){
return true;
}
}
return false;
}
}
kohaku_kohaku