結果

問題 No.240 ナイト散歩
ユーザー Tsukasa_Type
提出日時 2018-03-26 22:27:30
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 2,331 ms
コンパイル使用メモリ 79,352 KB
実行使用メモリ 57,256 KB
最終ジャッジ日時 2024-06-25 07:27:54
合計ジャッジ時間 12,349 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import static java.lang.System.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] dy = {-1,0,1,0};
	static int[] dx = {0,1,0,-1};
	static int gx = sc.nextInt();
	static int gy = sc.nextInt();
	public static void main(String[] args) {
		out.println(dfs(0,0,0)?"YES":"NO");
	}
	static boolean dfs(int x, int y, int n) {
		out.println(x+":"+y);
		if (n>3) return false;
		if (x==gx && y==gy) return true;
		return (
				dfs(x-2,y-1,n+1) ||
				dfs(x-2,y+1,n+1) ||
				dfs(x-1,y-2,n+1) ||
				dfs(x-1,y+2,n+1) ||
				dfs(x+1,y-2,n+1) ||
				dfs(x+1,y+2,n+1) ||
				dfs(x+2,y-1,n+1) ||
				dfs(x+2,y+1,n+1)
		);
	}
}
0