結果

問題 No.240 ナイト散歩
ユーザー code-devocode-devo
提出日時 2016-01-25 08:20:39
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 910 bytes
コンパイル時間 15,060 ms
コンパイル使用メモリ 222,880 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 19:39:33
合計ジャッジ時間 13,901 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 1 ms
6,944 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 1 ms
6,940 KB
testcase_33 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Point struct {
	x, y int
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan(); x, _ := strconv.Atoi(sc.Text())
	sc.Scan(); y, _ := strconv.Atoi(sc.Text())

	offsets := []Point{
		Point{-2, -1},
		Point{-2, +1},
		Point{-1, -2},
		Point{-1, +2},
		Point{+1, -2},
		Point{+1, +2},
		Point{+2, -1},
		Point{+2, +1},
	}

	visited := make(map[Point]bool)
	visited[Point{0, 0}] = true

	for i := 0; i < 3; i++ {
		points_to := make(map[Point]bool)
		for point, _ := range visited {
			for _, offset := range offsets {
				point_to := Point{point.x + offset.x, point.y + offset.y}
				if (!visited[point_to]) {
					points_to[point_to] = true
				}
			}
		}

		for point_to, _ := range points_to {
			visited[point_to] = true
		}
	}

	if visited[Point{x, y}] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
0