結果

問題 No.240 ナイト散歩
ユーザー GrenacheGrenache
提出日時 2015-07-10 22:39:40
言語 Java19
(openjdk 21)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 3,348 ms
コンパイル使用メモリ 74,456 KB
実行使用メモリ 56,780 KB
最終ジャッジ日時 2023-07-29 13:28:58
合計ジャッジ時間 8,301 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
55,508 KB
testcase_01 AC 107 ms
55,836 KB
testcase_02 AC 113 ms
55,524 KB
testcase_03 AC 108 ms
56,200 KB
testcase_04 AC 107 ms
55,608 KB
testcase_05 AC 106 ms
55,552 KB
testcase_06 AC 108 ms
56,456 KB
testcase_07 AC 112 ms
55,516 KB
testcase_08 AC 106 ms
55,416 KB
testcase_09 AC 107 ms
56,116 KB
testcase_10 AC 109 ms
55,632 KB
testcase_11 AC 109 ms
55,832 KB
testcase_12 AC 110 ms
55,948 KB
testcase_13 AC 109 ms
55,828 KB
testcase_14 AC 114 ms
55,928 KB
testcase_15 AC 109 ms
55,908 KB
testcase_16 AC 110 ms
55,940 KB
testcase_17 AC 112 ms
55,772 KB
testcase_18 AC 114 ms
55,768 KB
testcase_19 AC 111 ms
56,780 KB
testcase_20 AC 111 ms
55,780 KB
testcase_21 AC 111 ms
55,948 KB
testcase_22 AC 105 ms
55,940 KB
testcase_23 AC 107 ms
55,976 KB
testcase_24 AC 106 ms
55,760 KB
testcase_25 AC 114 ms
55,508 KB
testcase_26 AC 107 ms
55,968 KB
testcase_27 AC 110 ms
55,500 KB
testcase_28 AC 110 ms
55,944 KB
testcase_29 AC 109 ms
55,660 KB
testcase_30 AC 105 ms
55,580 KB
testcase_31 AC 109 ms
55,880 KB
testcase_32 AC 108 ms
55,708 KB
testcase_33 AC 106 ms
55,856 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