結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2020-03-19 16:19:42 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 628 bytes |
コンパイル時間 | 3,766 ms |
コンパイル使用メモリ | 77,848 KB |
実行使用メモリ | 56,356 KB |
最終ジャッジ日時 | 2024-12-14 03:17:09 |
合計ジャッジ時間 | 9,323 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 19 WA * 11 |
ソースコード
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);}}