結果

問題 No.168 ものさし
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-07 05:36:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,599 ms / 2,000 ms
コード長 1,533 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 151,984 KB
最終ジャッジ日時 2024-04-25 09:04:40
合計ジャッジ時間 12,973 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 314 ms
91,392 KB
testcase_01 AC 37 ms
52,480 KB
testcase_02 AC 37 ms
52,224 KB
testcase_03 AC 38 ms
52,352 KB
testcase_04 AC 37 ms
52,352 KB
testcase_05 AC 38 ms
52,096 KB
testcase_06 AC 37 ms
52,224 KB
testcase_07 AC 38 ms
52,096 KB
testcase_08 AC 38 ms
52,224 KB
testcase_09 AC 56 ms
62,464 KB
testcase_10 AC 75 ms
65,920 KB
testcase_11 AC 293 ms
91,264 KB
testcase_12 AC 1,019 ms
125,440 KB
testcase_13 AC 1,574 ms
151,872 KB
testcase_14 AC 1,575 ms
151,984 KB
testcase_15 AC 38 ms
52,480 KB
testcase_16 AC 53 ms
61,056 KB
testcase_17 AC 63 ms
64,640 KB
testcase_18 AC 100 ms
69,760 KB
testcase_19 AC 1,497 ms
150,324 KB
testcase_20 AC 1,579 ms
151,948 KB
testcase_21 AC 1,584 ms
151,688 KB
testcase_22 AC 1,599 ms
151,712 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 length(dist):
    l = 0
    r = 10 ** 10
    while r - l > 1:
        m = (l + r) // 2
        if m * m * 100 >= dist:
            r = m
        else:
            l = m
    return r * 10


N = int(input())
XY = tuple(tuple(map(int, input().split())) for _ in range(N))
edge = []
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 = abs(x - xx)
        dy = abs(y - yy)
        edge.append((dx * dx + dy * dy, i, j))
edge.sort()

uf = UF_tree(N)
for L, x, y in edge:
    if uf.unite(x, y) and uf.isSame(0, N - 1):
        break
print(length(L))
0