結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,736 KB
testcase_01 AC 123 ms
56,092 KB
testcase_02 AC 123 ms
55,992 KB
testcase_03 AC 124 ms
55,836 KB
testcase_04 AC 122 ms
55,944 KB
testcase_05 AC 124 ms
56,272 KB
testcase_06 AC 124 ms
55,668 KB
testcase_07 AC 122 ms
55,632 KB
testcase_08 AC 121 ms
55,656 KB
testcase_09 AC 122 ms
56,108 KB
testcase_10 AC 121 ms
55,992 KB
testcase_11 AC 119 ms
55,964 KB
testcase_12 AC 120 ms
55,740 KB
testcase_13 AC 122 ms
56,048 KB
testcase_14 AC 123 ms
56,008 KB
testcase_15 AC 121 ms
55,804 KB
testcase_16 AC 120 ms
55,380 KB
testcase_17 AC 119 ms
55,928 KB
testcase_18 AC 119 ms
55,948 KB
testcase_19 AC 122 ms
55,880 KB
testcase_20 AC 122 ms
55,940 KB
testcase_21 AC 120 ms
55,792 KB
testcase_22 AC 122 ms
55,984 KB
testcase_23 AC 121 ms
55,956 KB
testcase_24 AC 121 ms
56,004 KB
testcase_25 AC 120 ms
55,616 KB
testcase_26 AC 120 ms
55,920 KB
testcase_27 AC 121 ms
55,732 KB
testcase_28 AC 120 ms
56,024 KB
testcase_29 AC 122 ms
56,460 KB
testcase_30 AC 122 ms
56,140 KB
testcase_31 AC 121 ms
56,000 KB
testcase_32 AC 122 ms
55,840 KB
testcase_33 AC 123 ms
56,096 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 (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