結果
| 問題 |
No.168 ものさし
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2020-09-14 09:23:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,438 ms / 2,000 ms |
| コード長 | 1,145 bytes |
| コンパイル時間 | 1,650 ms |
| コンパイル使用メモリ | 82,332 KB |
| 実行使用メモリ | 146,568 KB |
| 最終ジャッジ日時 | 2024-06-22 00:37:51 |
| 合計ジャッジ時間 | 13,339 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines
class UnionFind:
def __init__(self, n):
self.n=n
self.par=[-1]*n
def find(self, x):
if self.par[x]<0:
return x
self.par[x]=self.find(self.par[x])
return self.par[x]
def unite(self, x, y):
x=self.find(x)
y=self.find(y)
if x==y:
return False
if self.par[x]<self.par[y]:
x, y=y, x
self.par[y]+=self.par[x]
self.par[x]=y
return True
def same(self, x, y):
return self.find(x)==self.find(y)
def size(self, x):
return -self.par[self.find(x)]
n=int(readline())
xy=list(map(int, read().split()))
x=xy[::2]
y=xy[1::2]
import itertools
es=[((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]), i, j) for i, j in itertools.combinations(range(n), 2)]
es.sort()
uf=UnionFind(n)
mn=0
for e in es:
uf.unite(e[1], e[2])
if uf.same(0, n-1):
mn=e[0]
break
l, r=0, 2*10**8
while r-l>1:
m=(l+r)//2
if 100*m*m>=mn:
r=m
else:
l=m
print(10*r)
chocorusk