結果

問題 No.240 ナイト散歩
ユーザー kou6839kou6839
提出日時 2015-07-16 19:30:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 967 bytes
コンパイル時間 2,267 ms
コンパイル使用メモリ 75,056 KB
実行使用メモリ 56,212 KB
最終ジャッジ日時 2023-09-22 16:45:39
合計ジャッジ時間 7,956 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,860 KB
testcase_01 AC 122 ms
55,952 KB
testcase_02 AC 121 ms
56,144 KB
testcase_03 AC 121 ms
56,144 KB
testcase_04 AC 120 ms
55,756 KB
testcase_05 AC 125 ms
55,944 KB
testcase_06 AC 126 ms
56,052 KB
testcase_07 AC 121 ms
55,788 KB
testcase_08 AC 124 ms
55,756 KB
testcase_09 AC 127 ms
55,920 KB
testcase_10 AC 123 ms
55,876 KB
testcase_11 AC 122 ms
55,832 KB
testcase_12 AC 123 ms
56,036 KB
testcase_13 AC 123 ms
55,908 KB
testcase_14 AC 123 ms
56,076 KB
testcase_15 AC 122 ms
56,036 KB
testcase_16 AC 122 ms
55,804 KB
testcase_17 AC 123 ms
56,188 KB
testcase_18 AC 120 ms
55,776 KB
testcase_19 AC 119 ms
55,468 KB
testcase_20 AC 116 ms
55,884 KB
testcase_21 AC 122 ms
55,800 KB
testcase_22 AC 119 ms
56,044 KB
testcase_23 AC 118 ms
55,736 KB
testcase_24 AC 121 ms
55,824 KB
testcase_25 AC 120 ms
55,592 KB
testcase_26 AC 120 ms
55,976 KB
testcase_27 AC 122 ms
55,792 KB
testcase_28 AC 121 ms
55,532 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 124 ms
55,792 KB
testcase_32 WA -
testcase_33 AC 124 ms
55,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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");
	}
}
0