結果

問題 No.240 ナイト散歩
ユーザー ぴろずぴろず
提出日時 2015-07-10 22:29:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 2,292 ms
コンパイル使用メモリ 85,680 KB
実行使用メモリ 56,044 KB
最終ジャッジ日時 2024-04-16 19:27:19
合計ジャッジ時間 7,980 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
54,308 KB
testcase_01 AC 133 ms
54,360 KB
testcase_02 AC 133 ms
54,136 KB
testcase_03 AC 134 ms
54,124 KB
testcase_04 AC 132 ms
54,488 KB
testcase_05 AC 133 ms
53,828 KB
testcase_06 AC 134 ms
54,048 KB
testcase_07 AC 132 ms
54,220 KB
testcase_08 AC 133 ms
54,208 KB
testcase_09 AC 132 ms
54,104 KB
testcase_10 AC 134 ms
54,012 KB
testcase_11 AC 136 ms
54,144 KB
testcase_12 AC 134 ms
54,316 KB
testcase_13 AC 133 ms
54,104 KB
testcase_14 AC 135 ms
54,124 KB
testcase_15 AC 135 ms
54,068 KB
testcase_16 AC 133 ms
54,416 KB
testcase_17 AC 134 ms
54,148 KB
testcase_18 AC 137 ms
54,052 KB
testcase_19 AC 136 ms
54,316 KB
testcase_20 AC 134 ms
54,196 KB
testcase_21 AC 132 ms
54,224 KB
testcase_22 AC 134 ms
53,980 KB
testcase_23 AC 133 ms
54,124 KB
testcase_24 AC 133 ms
54,388 KB
testcase_25 AC 133 ms
54,064 KB
testcase_26 AC 132 ms
54,172 KB
testcase_27 AC 135 ms
54,160 KB
testcase_28 AC 132 ms
54,148 KB
testcase_29 AC 135 ms
54,376 KB
testcase_30 AC 133 ms
53,944 KB
testcase_31 AC 136 ms
54,140 KB
testcase_32 AC 135 ms
54,164 KB
testcase_33 AC 135 ms
56,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no240;

import java.awt.Point;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static int[] dx = {-2,-2,-1,-1,1,1,2,2};
	static int[] dy = {-1,1,-2,2,-2,2,-1,1};
	public static void main(String[] args) {
		HashSet<Point> hs = new HashSet<>();
		hs.add(new Point(0,0));
		for(int i=0;i<3;i++) {
			HashSet<Point> hsn = new HashSet<>();
			for(Point p: hs) {
				for(int k=0;k<dx.length;k++) {
					hsn.add(new Point(p.x + dx[k], p.y + dy[k]));
				}
			}
			hs.addAll(hsn);
		}
		Scanner sc = new Scanner(System.in);
		if (hs.contains(new Point(sc.nextInt(),sc.nextInt()))) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

}
0