結果

問題 No.240 ナイト散歩
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-03-26 22:28:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 639 bytes
コンパイル時間 1,988 ms
コンパイル使用メモリ 77,032 KB
実行使用メモリ 56,548 KB
最終ジャッジ日時 2023-09-07 18:27:39
合計ジャッジ時間 7,639 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,768 KB
testcase_01 AC 121 ms
56,016 KB
testcase_02 AC 122 ms
55,736 KB
testcase_03 AC 121 ms
55,888 KB
testcase_04 AC 121 ms
56,052 KB
testcase_05 AC 121 ms
55,468 KB
testcase_06 AC 120 ms
55,808 KB
testcase_07 AC 122 ms
53,344 KB
testcase_08 AC 123 ms
55,728 KB
testcase_09 AC 121 ms
55,492 KB
testcase_10 AC 121 ms
55,476 KB
testcase_11 AC 122 ms
56,016 KB
testcase_12 AC 122 ms
55,804 KB
testcase_13 AC 121 ms
55,848 KB
testcase_14 AC 120 ms
55,920 KB
testcase_15 AC 120 ms
56,060 KB
testcase_16 AC 120 ms
55,652 KB
testcase_17 AC 119 ms
55,812 KB
testcase_18 AC 118 ms
56,548 KB
testcase_19 AC 119 ms
55,380 KB
testcase_20 AC 119 ms
55,708 KB
testcase_21 AC 121 ms
55,632 KB
testcase_22 AC 123 ms
55,852 KB
testcase_23 AC 123 ms
55,412 KB
testcase_24 AC 121 ms
53,624 KB
testcase_25 AC 122 ms
55,716 KB
testcase_26 AC 122 ms
55,716 KB
testcase_27 AC 124 ms
55,864 KB
testcase_28 AC 121 ms
55,496 KB
testcase_29 AC 121 ms
55,724 KB
testcase_30 AC 122 ms
56,032 KB
testcase_31 AC 121 ms
56,180 KB
testcase_32 AC 122 ms
55,640 KB
testcase_33 AC 122 ms
53,412 KB
権限があれば一括ダウンロードができます

ソースコード

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) {
		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