結果

問題 No.240 ナイト散歩
ユーザー GrenacheGrenache
提出日時 2015-07-10 22:39:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 3,588 ms
コンパイル使用メモリ 77,672 KB
実行使用メモリ 41,844 KB
最終ジャッジ日時 2024-04-16 19:28:46
合計ジャッジ時間 9,207 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
39,888 KB
testcase_01 AC 135 ms
41,504 KB
testcase_02 AC 133 ms
41,844 KB
testcase_03 AC 132 ms
41,128 KB
testcase_04 AC 132 ms
41,592 KB
testcase_05 AC 133 ms
41,824 KB
testcase_06 AC 134 ms
41,584 KB
testcase_07 AC 132 ms
41,280 KB
testcase_08 AC 132 ms
41,280 KB
testcase_09 AC 135 ms
41,288 KB
testcase_10 AC 133 ms
41,216 KB
testcase_11 AC 132 ms
41,444 KB
testcase_12 AC 134 ms
41,256 KB
testcase_13 AC 135 ms
41,272 KB
testcase_14 AC 133 ms
41,304 KB
testcase_15 AC 130 ms
41,556 KB
testcase_16 AC 134 ms
41,428 KB
testcase_17 AC 135 ms
41,456 KB
testcase_18 AC 133 ms
41,692 KB
testcase_19 AC 137 ms
41,608 KB
testcase_20 AC 132 ms
41,448 KB
testcase_21 AC 133 ms
41,800 KB
testcase_22 AC 117 ms
39,876 KB
testcase_23 AC 134 ms
41,444 KB
testcase_24 AC 134 ms
41,696 KB
testcase_25 AC 133 ms
41,528 KB
testcase_26 AC 134 ms
41,284 KB
testcase_27 AC 131 ms
41,388 KB
testcase_28 AC 132 ms
41,504 KB
testcase_29 AC 119 ms
40,244 KB
testcase_30 AC 136 ms
41,592 KB
testcase_31 AC 134 ms
41,524 KB
testcase_32 AC 135 ms
41,372 KB
testcase_33 AC 133 ms
41,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder240 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        x = sc.nextInt();
        y = sc.nextInt();

        if (dfs(0, 0, 0)) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }
        
        sc.close();
    }

    private static int x;
    private static int y;
    private static int[] dx = {1, 1, 2, 2, -1, -1, -2, -2};
    private static int[] dy = {2, -2, 1, -1, 2, -2, 1, -1};
    
	private static boolean dfs(int xx, int yy, int i) {
		if (xx == x && yy == y) {
			return true;
		}

		if (i == 3) {
			return false;
		}
		
		for (int j = 0; j < dx.length; j++) {
			int tmpx = xx + dx[j];
			int tmpy = yy + dy[j];
			if (dfs(tmpx, tmpy, i + 1)) {
				return true;
			}
		}

		return false;
	}
}
0