結果
| 問題 |
No.96 圏外です。
|
| コンテスト | |
| ユーザー |
ytft
|
| 提出日時 | 2022-11-12 06:07:43 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,387 bytes |
| コンパイル時間 | 125 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 71,696 KB |
| 最終ジャッジ日時 | 2024-09-13 22:48:57 |
| 合計ジャッジ時間 | 34,722 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 RE * 2 TLE * 2 -- * 17 |
ソースコード
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)
ytft