結果

問題 No.240 ナイト散歩
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-03-26 22:29:10
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 577 bytes
コンパイル時間 6,083 ms
コンパイル使用メモリ 71,292 KB
実行使用メモリ 56,556 KB
最終ジャッジ日時 2023-09-07 18:27:52
合計ジャッジ時間 7,450 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,728 KB
testcase_01 AC 120 ms
55,760 KB
testcase_02 AC 123 ms
55,636 KB
testcase_03 AC 120 ms
55,792 KB
testcase_04 AC 120 ms
55,884 KB
testcase_05 AC 121 ms
55,788 KB
testcase_06 AC 122 ms
56,004 KB
testcase_07 AC 122 ms
55,728 KB
testcase_08 AC 124 ms
55,920 KB
testcase_09 AC 122 ms
55,480 KB
testcase_10 AC 120 ms
55,724 KB
testcase_11 AC 120 ms
55,484 KB
testcase_12 AC 120 ms
56,244 KB
testcase_13 AC 119 ms
55,888 KB
testcase_14 AC 122 ms
55,904 KB
testcase_15 AC 121 ms
56,352 KB
testcase_16 AC 122 ms
56,144 KB
testcase_17 AC 123 ms
55,964 KB
testcase_18 AC 121 ms
56,276 KB
testcase_19 AC 122 ms
55,872 KB
testcase_20 AC 124 ms
55,880 KB
testcase_21 AC 119 ms
55,984 KB
testcase_22 AC 120 ms
56,004 KB
testcase_23 AC 120 ms
55,880 KB
testcase_24 AC 120 ms
56,096 KB
testcase_25 AC 120 ms
55,868 KB
testcase_26 AC 119 ms
55,888 KB
testcase_27 AC 120 ms
55,388 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 120 ms
55,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	static Scanner sc = new Scanner(System.in);
	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) {
		if (x==gx && y==gy) return true;
		if (n>3) return false;
		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