結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2018-10-21 12:31:32 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 137 ms / 2,000 ms |
コード長 | 611 bytes |
コンパイル時間 | 2,189 ms |
コンパイル使用メモリ | 75,000 KB |
実行使用メモリ | 41,528 KB |
最終ジャッジ日時 | 2024-11-19 03:19:34 |
合計ジャッジ時間 | 8,171 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
import java.util.Scanner;public class Main {@SuppressWarnings("resource")public static void main(String args[]) {Scanner scanner = new Scanner(System.in);int x=scanner.nextInt();int y=scanner.nextInt();int xs[]={-2,-2,-1,-1,1,1,2,2};int ys[]={-1,1,-2,2,-2,2,-1,1};dfs(0,0,0,x,y,xs,ys);System.out.println(bo?"YES":"NO");}static boolean bo=false;private static void dfs(int i, int x, int y,int gx,int gy, int[] xs, int[] ys) {if(x==gx&&y==gy){bo=true;return;}if(i==3){return;}for(int j=0;j<8;j++){dfs(i+1,x+xs[j],y+ys[j],gx,gy,xs,ys);}}}