結果

問題 No.168 ものさし
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-07 05:44:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 431 ms / 2,000 ms
コード長 1,501 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 85,760 KB
最終ジャッジ日時 2024-04-25 09:10:26
合計ジャッジ時間 4,638 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
78,976 KB
testcase_01 AC 37 ms
52,480 KB
testcase_02 AC 40 ms
52,352 KB
testcase_03 AC 40 ms
52,224 KB
testcase_04 AC 39 ms
52,224 KB
testcase_05 AC 39 ms
52,224 KB
testcase_06 AC 50 ms
60,160 KB
testcase_07 AC 41 ms
52,352 KB
testcase_08 AC 40 ms
52,352 KB
testcase_09 AC 92 ms
76,416 KB
testcase_10 AC 105 ms
76,800 KB
testcase_11 AC 171 ms
78,592 KB
testcase_12 AC 325 ms
82,688 KB
testcase_13 AC 431 ms
84,736 KB
testcase_14 AC 413 ms
84,608 KB
testcase_15 AC 40 ms
52,736 KB
testcase_16 AC 92 ms
76,416 KB
testcase_17 AC 101 ms
76,928 KB
testcase_18 AC 121 ms
77,312 KB
testcase_19 AC 285 ms
84,480 KB
testcase_20 AC 321 ms
84,608 KB
testcase_21 AC 303 ms
85,760 KB
testcase_22 AC 297 ms
85,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
inf = 10**18


class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)
        self.rank = [0] * (n + 1)

    def find(self, x):
        if self.root[x] < 0:
            return x
        self.root[x] = self.find(self.root[x])
        return self.root[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return True

    def size(self, x):
        return -self.root[self.find(x)]


def mst(v):
    uf = UF_tree(N)
    for i in range(N - 1):
        for j in range(i + 1, N):
            if G[i][j] <= v:
                uf.unite(i, j)
    return uf.isSame(0, N-1)


N = int(input())
XY = tuple(tuple(map(int, input().split())) for _ in range(N))
G = [[0] * N for _ in range(N)]
for i in range(N):
    x, y = XY[i]
    for j in range(i + 1, N):
        xx, yy = XY[j]
        dx = x - xx
        dy = y - yy
        G[i][j] = dx * dx + dy * dy

l = 0
r = 10 ** 10
while r - l > 1:
    m = (r + l) // 2
    if mst(m * m * 100):
        r = m
    else:
        l = m

print(r * 10)
0