結果

問題 No.240 ナイト散歩
ユーザー rf141rf141
提出日時 2015-07-27 22:30:22
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 742 bytes
コンパイル時間 4,803 ms
コンパイル使用メモリ 71,992 KB
実行使用メモリ 835,592 KB
最終ジャッジ日時 2023-09-23 04:06:07
合計ジャッジ時間 7,792 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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";
		}

	}
}
0