結果
| 問題 |
No.240 ナイト散歩
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-27 22:30:22 |
| 言語 | Java (openjdk 23) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 742 bytes |
| コンパイル時間 | 3,542 ms |
| コンパイル使用メモリ | 75,684 KB |
| 実行使用メモリ | 832,644 KB |
| 最終ジャッジ日時 | 2024-07-16 04:15:43 |
| 合計ジャッジ時間 | 7,547 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | MLE * 1 -- * 29 |
ソースコード
import java.util.*;
public class walkChess{
static int x;
static int y;
static final int[] canMove_x = {-2,-2,-1,-1,1,1,2,2};
static final int[] canMove_y = {-1,1,-2,2,-2,2,-1,1};
public static void main(String... args){
int base_x = 0,base_y = 0;
Scanner s = new Scanner(System.in);
x = s.nextInt();
y = s.nextInt();
System.out.println(judge(0,0,0));
}
public static String judge(int px,int py,int cw){
int count = cw;
if(px == x && py == y){
return "YES";
}else if(cw == 3){
return "NO";
}else{
for(int i = 0; i < 8; i++){
int after_x = px+canMove_x[i];
int after_y = py+canMove_y[i];
if(judge(after_x,after_y,count++).equals("YES")){
return "YES";
}
}
return "NO";
}
}
}