結果
問題 |
No.94 圏外です。(EASY)
|
ユーザー |
![]() |
提出日時 | 2019-09-07 16:32:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,316 bytes |
コンパイル時間 | 386 ms |
コンパイル使用メモリ | 82,460 KB |
実行使用メモリ | 85,780 KB |
最終ジャッジ日時 | 2024-06-26 21:35:11 |
合計ジャッジ時間 | 2,947 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 16 RE * 1 |
ソースコード
n = int(input()) xy = [list(map(int, input().split())) for i in range(n)] data=[[-1]*(10**3) for i in range(10**3)] ans=0 if n==0: print(1) exit() class UnionFind: __slots__ = ['id'] def __init__(self, n): self.id = [-1] * n def root(self, x): if self.id[x] < 0: return x else: self.id[x] = self.root(self.id[x]) return self.id[x] def find(self, x, y): return self.root(x) == self.root(y) def union(self, x, y): s1, s2 = self.root(x), self.root(y) if s1 != s2: if self.id[s1] <= self.id[s2]: self.id[s1] += self.id[s2] self.id[s2] = s1 else: self.id[s2] += self.id[s1] self.id[s1] = s2 return True return False uf =UnionFind(n) for i in range(n): x,y=xy[i] data[x][y]=i for k in range(n): x,y=xy[k] for i in range(-10,11): for j in range(-10,11): if data[i][j]>=0: if (x-i)**2+(y-j)**2<=100: uf.union(k,data[i][j]) for i in range(n): for j in range(n): if uf.find(i,j): x1,y1=xy[i] x2,y2=xy[j] ans=max(ans,(x1-x2)**2+(y1-y2)**2) print(ans**(0.5)+2)