結果

問題 No.96 圏外です。
ユーザー ytftytft
提出日時 2022-11-12 06:07:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,387 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 10,780 KB
実行使用メモリ 105,080 KB
最終ジャッジ日時 2023-10-11 22:58:28
合計ジャッジ時間 28,698 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 259 ms
105,080 KB
testcase_01 AC 266 ms
49,140 KB
testcase_02 AC 292 ms
49,864 KB
testcase_03 AC 266 ms
49,320 KB
testcase_04 AC 702 ms
50,668 KB
testcase_05 AC 1,008 ms
50,292 KB
testcase_06 AC 1,418 ms
51,656 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np
from scipy.spatial import ConvexHull
input=lambda:sys.stdin.readline().rstrip()
class unionFind:
    def __init__(self,N):
        self.N=N
        self.parent=[-1 for i in range(N)]
        self.size=[1 for i in range(N)]
    def find(self,x):
        path=[x]
        while self.parent[path[-1]]!=-1:
            path.append(self.parent[path[-1]])
        for i in path[:-1]:
            self.parent[i]=path[-1]
        return path[-1]
    def unite(self,x,y):
        roots=sorted([self.find(x),self.find(y)],key=lambda _:self.parent[_])
        if roots[0]!=roots[1]:
            self.parent[roots[0]]=roots[1]
            self.size[roots[1]]+=self.size[roots[0]]
def calc(A):
	if len(A)<3:
		return (A[0][0]-A[-1][0])**2+(A[0][1]-A[-1][1])**2
	C=ConvexHull(A).vertices
	ans=0
	for i in C:
		for j in C:
			ans=max(ans,(A[i][0]-A[j][0])**2+(A[i][1]-A[j][1])**2)
	return ans
N=int(input())
if N==0:
	print(1)
	sys.exit()
ans=0
pos={}
check={}
u=unionFind(N)
for i in range(N):
	pos[tuple(map(int,input().split()))]=i
for i in pos:
	for j in range(-10,11):
		for k in range(-10,11):
			if not 0<j**2+k**2<=100:
				continue
			if (i[0]+j,i[1]+k) in pos:
				u.unite(pos[i],pos[(i[0]+j,i[1]+k)])
for i in pos:
	key=u.find(pos[i])
	if not key in check:
		check[key]=[]
	check[key].append(i)
for i in check:
	ans=max(ans,calc(check[i]))
print(pow(ans,0.5)+2)
0