結果

問題 No.240 ナイト散歩
コンテスト
ユーザー tsunabit
提出日時 2020-03-19 16:20:26
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 628 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,026 ms
コンパイル使用メモリ 82,248 KB
実行使用メモリ 43,132 KB
最終ジャッジ日時 2026-05-24 21:49:23
合計ジャッジ時間 8,625 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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