結果

問題 No.240 ナイト散歩
ユーザー kou6839kou6839
提出日時 2015-07-16 19:33:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 838 bytes
コンパイル時間 2,269 ms
コンパイル使用メモリ 78,240 KB
実行使用メモリ 41,692 KB
最終ジャッジ日時 2024-04-16 19:31:48
合計ジャッジ時間 8,281 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,272 KB
testcase_01 AC 138 ms
41,412 KB
testcase_02 AC 136 ms
41,276 KB
testcase_03 AC 140 ms
41,620 KB
testcase_04 AC 135 ms
41,408 KB
testcase_05 AC 137 ms
41,368 KB
testcase_06 AC 137 ms
41,316 KB
testcase_07 AC 137 ms
41,020 KB
testcase_08 AC 135 ms
41,652 KB
testcase_09 AC 139 ms
41,316 KB
testcase_10 AC 136 ms
41,588 KB
testcase_11 AC 135 ms
41,284 KB
testcase_12 AC 135 ms
41,432 KB
testcase_13 AC 137 ms
41,652 KB
testcase_14 AC 134 ms
41,496 KB
testcase_15 AC 134 ms
41,692 KB
testcase_16 AC 134 ms
41,284 KB
testcase_17 AC 136 ms
41,620 KB
testcase_18 AC 132 ms
41,560 KB
testcase_19 AC 132 ms
41,388 KB
testcase_20 AC 141 ms
41,408 KB
testcase_21 AC 135 ms
41,260 KB
testcase_22 AC 137 ms
41,276 KB
testcase_23 AC 134 ms
41,292 KB
testcase_24 AC 135 ms
41,464 KB
testcase_25 AC 135 ms
41,524 KB
testcase_26 AC 135 ms
41,436 KB
testcase_27 AC 134 ms
41,492 KB
testcase_28 AC 135 ms
41,380 KB
testcase_29 AC 134 ms
41,576 KB
testcase_30 AC 133 ms
41,196 KB
testcase_31 AC 135 ms
41,424 KB
testcase_32 AC 134 ms
41,628 KB
testcase_33 AC 135 ms
41,488 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);
				}
			}
		}
		System.out.println("NO");
	}
}
0