結果
| 問題 |
No.240 ナイト散歩
|
| コンテスト | |
| ユーザー |
kou6839
|
| 提出日時 | 2015-07-16 19:30:23 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 967 bytes |
| コンパイル時間 | 3,036 ms |
| コンパイル使用メモリ | 77,944 KB |
| 実行使用メモリ | 44,304 KB |
| 最終ジャッジ日時 | 2024-07-08 08:13:22 |
| 合計ジャッジ時間 | 6,773 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 WA * 3 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] dx = {-2,-2,-1,-1,1,1,2,2};
int[] dy = {-1,1,-2,2,-2,2,-1,1};
Queue<Integer> xque = new LinkedList<>();
Queue<Integer> yque = new LinkedList<>();
int X = sc.nextInt();
int Y = sc.nextInt();
if(X==0 && Y == 0){
System.out.println("YES");
return;
}
xque.add(0);
yque.add(0);
for(int i=0;i<3;i++){
int len = xque.size();
for(int j=0;j<len;j++){
int nowx = xque.poll();
int nowy = yque.poll();
for(int k=0;k<dx.length;k++){
int nextx = nowx + dx[k];
int nexty = nowy + dy[k];
if(X == nextx && Y == nexty){
System.out.println("YES");
return;
}
xque.add(nextx);
yque.add(nexty);
}
}
}
for(int i=0;i<xque.size();i++){
if(X==xque.poll() && Y == yque.poll()){
System.out.println("YES");
return;
}
}
System.out.println("NO");
}
}
kou6839