結果

問題 No.240 ナイト散歩
コンテスト
ユーザー rf141
提出日時 2015-07-27 22:30:22
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
MLE  
実行時間 -
コード長 742 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,511 ms
コンパイル使用メモリ 82,144 KB
実行使用メモリ 884,052 KB
最終ジャッジ日時 2026-03-30 18:41:17
合計ジャッジ時間 43,787 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 MLE * 3
other MLE * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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