結果

問題 No.240 ナイト散歩
ユーザー ぴろずぴろず
提出日時 2015-07-10 22:29:25
言語 Java
(openjdk 23)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 2,389 ms
コンパイル使用メモリ 78,764 KB
実行使用メモリ 54,252 KB
最終ジャッジ日時 2024-10-07 20:47:15
合計ジャッジ時間 7,249 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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