結果

問題 No.202 1円玉投げ
ユーザー aru aruaru aru
提出日時 2020-09-12 11:11:58
言語 Go
(1.22.1)
結果
AC  
実行時間 106 ms / 5,000 ms
コード長 1,771 bytes
コンパイル時間 14,503 ms
コンパイル使用メモリ 213,480 KB
実行使用メモリ 36,400 KB
最終ジャッジ日時 2023-08-24 00:16:30
合計ジャッジ時間 15,396 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
14,180 KB
testcase_01 AC 102 ms
35,412 KB
testcase_02 AC 13 ms
7,096 KB
testcase_03 AC 13 ms
7,100 KB
testcase_04 AC 13 ms
7,096 KB
testcase_05 AC 36 ms
23,576 KB
testcase_06 AC 95 ms
35,012 KB
testcase_07 AC 100 ms
35,140 KB
testcase_08 AC 100 ms
35,172 KB
testcase_09 AC 84 ms
36,400 KB
testcase_10 AC 64 ms
32,340 KB
testcase_11 AC 78 ms
34,156 KB
testcase_12 AC 78 ms
34,096 KB
testcase_13 AC 64 ms
32,696 KB
testcase_14 AC 39 ms
24,924 KB
testcase_15 AC 82 ms
36,396 KB
testcase_16 AC 51 ms
14,204 KB
testcase_17 AC 52 ms
11,960 KB
testcase_18 AC 51 ms
11,956 KB
testcase_19 AC 81 ms
36,192 KB
testcase_20 AC 92 ms
34,816 KB
testcase_21 AC 81 ms
36,220 KB
testcase_22 AC 18 ms
10,864 KB
testcase_23 AC 18 ms
10,872 KB
testcase_24 AC 13 ms
7,112 KB
testcase_25 AC 13 ms
7,312 KB
testcase_26 AC 13 ms
7,112 KB
testcase_27 AC 13 ms
7,136 KB
testcase_28 AC 13 ms
7,112 KB
testcase_29 AC 14 ms
7,112 KB
testcase_30 AC 18 ms
10,476 KB
testcase_31 AC 13 ms
7,116 KB
testcase_32 AC 18 ms
10,540 KB
testcase_33 AC 14 ms
7,220 KB
testcase_34 AC 13 ms
7,116 KB
testcase_35 AC 50 ms
10,828 KB
testcase_36 AC 66 ms
15,304 KB
testcase_37 AC 106 ms
35,216 KB
testcase_38 AC 57 ms
11,972 KB
testcase_39 AC 14 ms
7,684 KB
testcase_40 AC 14 ms
7,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	x := make([]int, N)
	y := make([]int, N)
	var m [2010][2010][]int
	for i := 0; i < N; i++ {
		x[i], y[i] = getInt(), getInt()
	}
	cnt := 0
	for i := 0; i < N; i++ {
		xpos := (x[i]+19)/20 + 1
		ypos := (y[i]+19)/20 + 1
		flg := true
		// out(i, x[i], y[1], xpos, ypos)
	L0:
		for dx := -1; dx <= 1; dx++ {
			for dy := -1; dy <= 1; dy++ {
				xx := xpos + dx
				yy := ypos + dy
				// out("xx, yy", xx, yy)
				for _, e := range m[xx][yy] {
					rx := abs(x[i] - x[e])
					ry := abs(y[i] - y[e])
					// out(i, ":", x[i], y[i], "vs", e, ":", x[e], y[e], rx, ry)
					if rx*rx+ry*ry < 400 {
						flg = false
						break L0
					}
				}
			}
		}
		if flg {
			m[xpos][ypos] = append(m[xpos][ypos], i)
			cnt++
		}
	}
	out(cnt)
}
0