結果

問題 No.240 ナイト散歩
ユーザー r.suzukir.suzuki
提出日時 2015-12-30 18:17:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 3,777 ms
コンパイル使用メモリ 78,920 KB
実行使用メモリ 47,704 KB
最終ジャッジ日時 2024-04-16 19:38:52
合計ジャッジ時間 8,609 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
41,008 KB
testcase_01 AC 127 ms
41,348 KB
testcase_02 AC 131 ms
41,192 KB
testcase_03 AC 125 ms
41,260 KB
testcase_04 AC 119 ms
41,128 KB
testcase_05 AC 127 ms
41,212 KB
testcase_06 AC 124 ms
41,040 KB
testcase_07 AC 120 ms
41,296 KB
testcase_08 AC 131 ms
41,356 KB
testcase_09 AC 124 ms
41,488 KB
testcase_10 AC 114 ms
41,224 KB
testcase_11 AC 119 ms
39,800 KB
testcase_12 AC 129 ms
41,264 KB
testcase_13 AC 124 ms
40,040 KB
testcase_14 AC 131 ms
41,452 KB
testcase_15 AC 129 ms
41,052 KB
testcase_16 AC 128 ms
40,916 KB
testcase_17 AC 124 ms
41,424 KB
testcase_18 AC 124 ms
41,136 KB
testcase_19 AC 130 ms
41,128 KB
testcase_20 AC 126 ms
47,704 KB
testcase_21 AC 122 ms
40,272 KB
testcase_22 AC 126 ms
41,612 KB
testcase_23 AC 112 ms
41,624 KB
testcase_24 AC 110 ms
41,296 KB
testcase_25 AC 120 ms
39,856 KB
testcase_26 AC 121 ms
39,936 KB
testcase_27 AC 124 ms
40,272 KB
testcase_28 AC 129 ms
41,384 KB
testcase_29 AC 128 ms
41,064 KB
testcase_30 AC 130 ms
41,180 KB
testcase_31 AC 125 ms
39,792 KB
testcase_32 AC 123 ms
41,016 KB
testcase_33 AC 125 ms
41,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

enum Step {
	p1(1, 2), p2(2, 1), p3(2, -1), p4(1, -2), p5(-1, -2), p6(-2, -1), p7(-2, 1), p8(-1, 2);
	int x, y;

	Step(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

public class No_240 {
	static int decideX;
	static int decideY;

	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		decideX = sc.nextInt();
		decideY = sc.nextInt();
		String ans = "";

		if (Knight(0, 0, 0)) {
			ans = "YES";
		} else {
			ans = "NO";
		}

		System.out.println(ans);
		sc.close();

	}

	static boolean Knight(int x, int y, int c) {

		if (judge(x, y)) {
			return true;
		}
		if (c >= 3) {
			return false;
		}
		for (Step s : Step.values()) {
			int nextX = x + s.x;
			int nextY = y + s.y;
			if (Knight(nextX, nextY, c + 1)) {
				return true;
			}
		}
		return false;
	}

	static boolean judge(int x, int y) {
		if (decideX == x && decideY == y) {
			return true;
		} else {
			return false;
		}
	}

}
0