結果

問題 No.240 ナイト散歩
ユーザー uafr_csuafr_cs
提出日時 2015-07-31 19:56:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 2,437 ms
コンパイル使用メモリ 78,056 KB
実行使用メモリ 41,532 KB
最終ジャッジ日時 2024-04-16 19:33:43
合計ジャッジ時間 7,944 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
41,284 KB
testcase_01 AC 135 ms
41,384 KB
testcase_02 AC 134 ms
41,104 KB
testcase_03 AC 136 ms
41,428 KB
testcase_04 AC 135 ms
41,280 KB
testcase_05 AC 120 ms
40,128 KB
testcase_06 AC 135 ms
41,404 KB
testcase_07 AC 134 ms
41,148 KB
testcase_08 AC 134 ms
41,352 KB
testcase_09 AC 131 ms
41,328 KB
testcase_10 AC 130 ms
41,304 KB
testcase_11 AC 122 ms
40,352 KB
testcase_12 AC 136 ms
41,356 KB
testcase_13 AC 136 ms
41,388 KB
testcase_14 AC 134 ms
41,048 KB
testcase_15 AC 134 ms
40,976 KB
testcase_16 AC 120 ms
40,388 KB
testcase_17 AC 135 ms
41,508 KB
testcase_18 AC 135 ms
41,188 KB
testcase_19 AC 136 ms
41,200 KB
testcase_20 AC 134 ms
41,052 KB
testcase_21 AC 134 ms
41,180 KB
testcase_22 AC 133 ms
41,308 KB
testcase_23 AC 134 ms
41,532 KB
testcase_24 AC 133 ms
41,308 KB
testcase_25 AC 135 ms
41,052 KB
testcase_26 AC 136 ms
41,324 KB
testcase_27 AC 134 ms
41,152 KB
testcase_28 AC 135 ms
41,272 KB
testcase_29 AC 135 ms
41,320 KB
testcase_30 AC 136 ms
41,256 KB
testcase_31 AC 135 ms
41,272 KB
testcase_32 AC 136 ms
41,316 KB
testcase_33 AC 134 ms
41,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static final int[] vs = {1, 2, 2, 1, -1, -2, -2, -1};
	
	public static boolean dfs(final int X, final int Y, int rest, int k_x, int k_y){
		if(X == k_x && Y == k_y){
			return true;
		}else if(rest <= 0){
			return false;
		}
		
		for(int index = 0; index < vs.length; index++){
			final int dx = vs[index];
			final int dy = vs[(index + vs.length / 4) % vs.length];
			
			if(dfs(X, Y, rest - 1, k_x + dx, k_y + dy)){
				return true;
			}
		}
		
		return false;
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int X = sc.nextInt();
		final int Y = sc.nextInt();
		
		System.out.println(dfs(X, Y, 3, 0, 0) ? "YES" : "NO");
		
		
	}
	
}
0