結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2015-08-14 21:27:46 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 144 ms / 2,000 ms |
コード長 | 962 bytes |
コンパイル時間 | 4,085 ms |
コンパイル使用メモリ | 80,576 KB |
実行使用メモリ | 54,504 KB |
最終ジャッジ日時 | 2024-10-07 21:04:28 |
合計ジャッジ時間 | 10,083 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
import java.util.*;import java.io.*;import java.awt.geom.*;import java.math.*;public class No0240 {static final Scanner in = new Scanner(System.in);static final PrintWriter out = new PrintWriter(System.out,false);static void solve() {X = in.nextInt();Y = in.nextInt();out.println(rec(0,0,0) ? "YES" : "NO");}static int X,Y;static int[] dx = {-2,-2,-1,-1,1,1,2,2};static int[] dy = {-1,1,-2,2,-2,2,-1,1};static boolean rec(int x, int y, int depth) {if (x == X && y == Y) return true;if (depth == 3) return false;for (int i=0; i<8; i++) {if (rec(x+dx[i],y+dy[i],depth+1)) {return true;}}return false;}public static void main(String[] args) {long start = System.currentTimeMillis();solve();out.flush();long end = System.currentTimeMillis();//trace(end-start + "ms");in.close();out.close();}static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}}