結果
| 問題 | No.96 圏外です。 |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-07-19 05:24:28 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 2,221 bytes |
| 記録 | |
| コンパイル時間 | 224 ms |
| コンパイル使用メモリ | 96,240 KB |
| 実行使用メモリ | 1,334,732 KB |
| 最終ジャッジ日時 | 2026-07-19 05:24:42 |
| 合計ジャッジ時間 | 13,279 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 MLE * 2 -- * 6 |
ソースコード
import sys
input = sys.stdin.readline
from collections import defaultdict
N=int(input())
if N==0:
print(1)
exit()
P=[list(map(int,input().split())) for i in range(N)]
for i in range(N):
P[i][0]+=10000
P[i][1]+=10000
# UnionFind
Group = [i for i in range(N)] # グループ分け
Nodes = [1]*(N) # 各グループのノードの数
def find(x):
while Group[x] != x:
x=Group[x]
return x
def Union(x,y):
if find(x) != find(y):
if Nodes[find(x)] < Nodes[find(y)]:
Nodes[find(y)] += Nodes[find(x)]
Nodes[find(x)] = 0
Group[find(x)] = find(y)
else:
Nodes[find(x)] += Nodes[find(y)]
Nodes[find(y)] = 0
Group[find(y)] = find(x)
LIST=defaultdict(list)
for i in range(N):
x,y=P[i]
LIST[(x//10,y//10)].append(i)
for C in LIST:
x,y=C
X=[]
if (x,y) in LIST:
X+=LIST[x,y]
if (x,y+1) in LIST:
X+=LIST[x,y+1]
if (x+1,y+1) in LIST:
X+=LIST[x+1,y+1]
if (x+1,y) in LIST:
X+=LIST[x+1,y]
if (x+1,y-1) in LIST:
X+=LIST[x+1,y-1]
#print(X)
for i in range(len(X)):
for j in range(i+1,len(X)):
a,b=P[X[i]]
c,d=P[X[j]]
if (a-c)*(a-c)+(b-d)*(b-d)<=10*10:
Union(X[i],X[j])
ANS=0
LX=defaultdict(list)
LX2=[set() for i in range(N)]
for i in range(N):
x,y=P[i]
LX[(x//10,y//10)].append(find(i))
LX2[find(i)].add((x//10,y//10))
for i in range(N):
if find(i)==i:
C=[]
LL=list(LX2[i])
for j in range(len(LL)):
for k in range(j,len(LL)):
a,b=LL[j]
c,d=LL[k]
C.append(((a-c)*(a-c)+(b-d)*(b-d),LL[j],LL[k]))
#print(C)
C.sort(reverse=True)
#print(C)
for ll,x,y in C:
if ll*100<ANS-2000:
break
for aa in LIST[x]:
for bb in LIST[y]:
if find(aa)==find(bb):
a,b=P[aa]
c,d=P[bb]
ANS=max(ANS,(a-c)*(a-c)+(b-d)*(b-d))
#print(ANS)
print(ANS**(1/2)+2)
titia