結果

問題 No.240 ナイト散歩
ユーザー rf141rf141
提出日時 2015-07-27 22:32:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 3,507 ms
コンパイル使用メモリ 77,960 KB
実行使用メモリ 54,392 KB
最終ジャッジ日時 2024-04-16 19:33:32
合計ジャッジ時間 9,157 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,000 KB
testcase_01 AC 135 ms
53,976 KB
testcase_02 AC 135 ms
54,108 KB
testcase_03 AC 130 ms
54,104 KB
testcase_04 AC 132 ms
54,244 KB
testcase_05 AC 135 ms
54,392 KB
testcase_06 AC 133 ms
54,064 KB
testcase_07 AC 134 ms
54,088 KB
testcase_08 AC 132 ms
54,212 KB
testcase_09 AC 133 ms
54,244 KB
testcase_10 AC 133 ms
54,024 KB
testcase_11 AC 130 ms
53,952 KB
testcase_12 AC 131 ms
53,876 KB
testcase_13 AC 133 ms
53,976 KB
testcase_14 AC 131 ms
54,048 KB
testcase_15 AC 133 ms
53,992 KB
testcase_16 AC 133 ms
54,080 KB
testcase_17 AC 133 ms
54,080 KB
testcase_18 AC 135 ms
54,340 KB
testcase_19 AC 132 ms
54,212 KB
testcase_20 AC 131 ms
53,996 KB
testcase_21 AC 133 ms
54,088 KB
testcase_22 AC 134 ms
54,036 KB
testcase_23 AC 133 ms
54,160 KB
testcase_24 AC 131 ms
54,188 KB
testcase_25 AC 135 ms
54,340 KB
testcase_26 AC 133 ms
54,088 KB
testcase_27 AC 133 ms
54,204 KB
testcase_28 AC 135 ms
54,360 KB
testcase_29 AC 134 ms
54,268 KB
testcase_30 AC 133 ms
54,060 KB
testcase_31 AC 133 ms
53,988 KB
testcase_32 AC 137 ms
53,836 KB
testcase_33 AC 134 ms
54,132 KB
権限があれば一括ダウンロードができます

ソースコード

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();
		if(judge(0,0,0)){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

	public static boolean judge(int px,int py,int cw){
		int count = cw;
		if(px == x && py == y){
			return true;
		}else if(cw == 3){
			return false;
		}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+1)){
					return true;
				}
			}
			return false;
		}

	}
}
0