結果

問題 No.94 圏外です。(EASY)
ユーザー ichyoichyo
提出日時 2014-12-07 19:53:35
言語 Go
(1.22.1)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 810 bytes
コンパイル時間 14,470 ms
コンパイル使用メモリ 208,848 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 14:13:02
合計ジャッジ時間 14,893 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,384 KB
testcase_06 AC 4 ms
4,384 KB
testcase_07 AC 7 ms
4,384 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 12 ms
4,384 KB
testcase_10 AC 11 ms
4,380 KB
testcase_11 AC 11 ms
4,380 KB
testcase_12 AC 12 ms
4,380 KB
testcase_13 AC 11 ms
4,380 KB
testcase_14 AC 12 ms
4,380 KB
testcase_15 AC 12 ms
4,380 KB
testcase_16 AC 12 ms
4,384 KB
testcase_17 AC 11 ms
4,384 KB
testcase_18 AC 11 ms
4,380 KB
testcase_19 AC 15 ms
4,384 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"math"
)

func norm(x, y int) int {
	return x*x + y*y
}

var res []int

func dfs(u int, used []bool, x, y []int) {
	if used[u] {
		return
	}
	res = append(res, u)
	used[u] = true
	for i, _ := range x {
		if norm(x[i]-x[u], y[i]-y[u]) <= 100 {
			dfs(i, used, x, y)
		}
	}
}
func main() {
	var n int
	fmt.Scan(&n)
	x := make([]int, n)
	y := make([]int, n)
	for i, _ := range x {
		fmt.Scan(&x[i], &y[i])
	}
	used := make([]bool, n)
	ans := 1.0
	for i, v := range used {
		if !v {
			res = make([]int, 0)
			dfs(i, used, x, y)
			for _, u := range res {
				for _, v := range res {
					d := 2 + math.Sqrt(float64(norm(x[u]-x[v], y[u]-y[v])))
					if ans < d {
						ans = d
					}
				}
			}
		}
	}
	fmt.Printf("%.12f\n", ans)
}
0