結果

問題 No.168 ものさし
ユーザー ayaoniayaoni
提出日時 2020-12-06 03:30:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 303 ms / 2,000 ms
コード長 1,759 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 85,076 KB
最終ジャッジ日時 2023-10-16 23:36:21
合計ジャッジ時間 4,792 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
78,892 KB
testcase_01 AC 36 ms
53,628 KB
testcase_02 AC 36 ms
53,628 KB
testcase_03 AC 36 ms
53,628 KB
testcase_04 AC 37 ms
53,628 KB
testcase_05 AC 37 ms
53,628 KB
testcase_06 AC 43 ms
61,704 KB
testcase_07 AC 36 ms
53,628 KB
testcase_08 AC 36 ms
53,628 KB
testcase_09 AC 84 ms
76,232 KB
testcase_10 AC 103 ms
76,620 KB
testcase_11 AC 148 ms
78,756 KB
testcase_12 AC 235 ms
82,424 KB
testcase_13 AC 303 ms
84,988 KB
testcase_14 AC 287 ms
85,008 KB
testcase_15 AC 38 ms
53,628 KB
testcase_16 AC 82 ms
76,268 KB
testcase_17 AC 99 ms
76,492 KB
testcase_18 AC 113 ms
76,740 KB
testcase_19 AC 252 ms
84,744 KB
testcase_20 AC 230 ms
85,076 KB
testcase_21 AC 230 ms
84,960 KB
testcase_22 AC 247 ms
85,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n+1)]  # 親のノード番号
        self.rank = [0]*(n+1)

    def find(self,x):  # xの根のノード番号
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self,x,y):  # x,yが同じグループか否か
        return self.find(x) == self.find(y)

    def unite(self,x,y):  # x,yの属するグループの併合
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            x,y = y,x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x


N = I()
XY = [(0,0)]+[tuple(MI()) for _ in range(N)]

dist = [[0]*(N+1) for _ in range(N+1)]
for i in range(1,N):
    x0,y0 = XY[i]
    for j in range(i+1,N+1):
        x1,y1 = XY[j]
        dist[i][j] = (x0-x1)**2+(y0-y1)**2


def f(z):
    UF = UnionFind(N)
    for i in range(1,N):
        for j in range(i+1,N+1):
            if dist[i][j] <= z**2:
                UF.unite(i,j)
    if UF.same_check(1,N):
        return True
    return False


ng = 0
ok = 2*10**8
while ng+1 < ok:
    mid = (ng+ok)//2
    if f(10*mid):
        ok = mid
    else:
        ng = mid

print(10*ok)
0