結果

問題 No.240 ナイト散歩
ユーザー tsunabittsunabit
提出日時 2020-03-19 16:20:26
言語 Java19
(openjdk 21)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 628 bytes
コンパイル時間 3,884 ms
コンパイル使用メモリ 73,832 KB
実行使用メモリ 55,984 KB
最終ジャッジ日時 2023-08-20 20:54:58
合計ジャッジ時間 10,024 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
53,928 KB
testcase_01 AC 125 ms
55,592 KB
testcase_02 AC 127 ms
53,816 KB
testcase_03 AC 127 ms
53,576 KB
testcase_04 AC 126 ms
55,704 KB
testcase_05 AC 126 ms
55,616 KB
testcase_06 AC 126 ms
55,616 KB
testcase_07 AC 126 ms
55,604 KB
testcase_08 AC 126 ms
55,616 KB
testcase_09 AC 129 ms
55,644 KB
testcase_10 AC 125 ms
55,408 KB
testcase_11 AC 124 ms
55,744 KB
testcase_12 AC 125 ms
55,844 KB
testcase_13 AC 125 ms
55,624 KB
testcase_14 AC 128 ms
55,652 KB
testcase_15 AC 125 ms
55,768 KB
testcase_16 AC 125 ms
55,388 KB
testcase_17 AC 124 ms
55,816 KB
testcase_18 AC 124 ms
55,888 KB
testcase_19 AC 127 ms
55,732 KB
testcase_20 AC 127 ms
55,648 KB
testcase_21 AC 126 ms
55,952 KB
testcase_22 AC 127 ms
55,904 KB
testcase_23 AC 126 ms
55,396 KB
testcase_24 AC 126 ms
55,572 KB
testcase_25 AC 126 ms
55,636 KB
testcase_26 AC 125 ms
54,208 KB
testcase_27 AC 126 ms
55,792 KB
testcase_28 AC 126 ms
55,588 KB
testcase_29 AC 126 ms
55,652 KB
testcase_30 AC 127 ms
55,984 KB
testcase_31 AC 124 ms
55,704 KB
testcase_32 AC 127 ms
55,612 KB
testcase_33 AC 125 ms
55,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No240 {
	public static String ans = "NO";
	public static int X;
	public static int Y;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		X = sc.nextInt();
		Y = sc.nextInt();
		bfs(0, 0, 0);
		System.out.println(ans);
	}
	public static void bfs(int x, int y, int c) {
		if(c > 3) return;
		if(x == X && y == Y) {
			ans = "YES";
			return;
		}
		bfs(x-2, y-1 ,c+1);
		bfs(x-2, y+1 ,c+1);
		bfs(x-1, y-2 ,c+1);
		bfs(x-1, y+2 ,c+1);
		bfs(x+1, y-2 ,c+1);
		bfs(x+1, y+2 ,c+1);
		bfs(x+2, y-1 ,c+1);
		bfs(x+2, y+1 ,c+1);
	}
}
0