結果

問題 No.240 ナイト散歩
ユーザー tsunabittsunabit
提出日時 2020-03-19 16:19:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 628 bytes
コンパイル時間 5,565 ms
コンパイル使用メモリ 74,152 KB
実行使用メモリ 39,644 KB
最終ジャッジ日時 2023-08-20 20:54:46
合計ジャッジ時間 7,828 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
39,388 KB
testcase_01 AC 103 ms
39,380 KB
testcase_02 WA -
testcase_03 AC 104 ms
39,152 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 102 ms
39,112 KB
testcase_07 WA -
testcase_08 AC 101 ms
39,396 KB
testcase_09 AC 101 ms
39,536 KB
testcase_10 AC 101 ms
39,392 KB
testcase_11 AC 102 ms
39,056 KB
testcase_12 AC 102 ms
39,400 KB
testcase_13 AC 108 ms
38,908 KB
testcase_14 AC 103 ms
39,644 KB
testcase_15 AC 104 ms
39,076 KB
testcase_16 AC 102 ms
39,004 KB
testcase_17 AC 105 ms
39,404 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 104 ms
39,228 KB
testcase_29 AC 108 ms
39,000 KB
testcase_30 AC 104 ms
39,448 KB
testcase_31 AC 103 ms
39,472 KB
testcase_32 AC 106 ms
39,044 KB
testcase_33 AC 105 ms
39,508 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