結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
|
| 提出日時 | 2016-01-25 08:20:39 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 910 bytes |
| コンパイル時間 | 15,805 ms |
| コンパイル使用メモリ | 246,948 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-07 21:19:56 |
| 合計ジャッジ時間 | 14,397 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
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")
}
}