結果

問題 No.168 ものさし
ユーザー rlangevinrlangevin
提出日時 2023-07-04 12:28:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 886 ms / 2,000 ms
コード長 1,348 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 79,484 KB
最終ジャッジ日時 2023-09-25 10:23:47
合計ジャッジ時間 9,994 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 303 ms
78,536 KB
testcase_01 AC 69 ms
70,952 KB
testcase_02 AC 69 ms
71,048 KB
testcase_03 AC 70 ms
71,280 KB
testcase_04 AC 71 ms
70,956 KB
testcase_05 AC 70 ms
71,408 KB
testcase_06 AC 76 ms
75,868 KB
testcase_07 AC 71 ms
71,212 KB
testcase_08 AC 69 ms
71,144 KB
testcase_09 AC 118 ms
77,456 KB
testcase_10 AC 145 ms
77,164 KB
testcase_11 AC 299 ms
77,996 KB
testcase_12 AC 645 ms
78,296 KB
testcase_13 AC 863 ms
78,928 KB
testcase_14 AC 844 ms
77,948 KB
testcase_15 AC 70 ms
71,212 KB
testcase_16 AC 124 ms
78,020 KB
testcase_17 AC 141 ms
77,792 KB
testcase_18 AC 182 ms
77,736 KB
testcase_19 AC 853 ms
78,624 KB
testcase_20 AC 872 ms
79,104 KB
testcase_21 AC 869 ms
78,832 KB
testcase_22 AC 886 ms
79,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != 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
            self.size[x] += self.size[y]

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

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
    

N = int(input())
X, Y = [0] * N, [0] * N
for i in range(N):
    X[i], Y[i] = map(int, input().split())


yes = 10 ** 10
no = -1

def check(m):
    U = UnionFind(N)
    for i in range(N):
        for j in range(i + 1, N):
            if (X[i] - X[j]) ** 2 + (Y[i] - Y[j]) ** 2 <= m ** 2:
                U.union(i, j)
    return U.is_same(0, N - 1)

while yes - no != 1:
    mid = (yes + no)//2
    if check(mid):
        yes = mid
    else:
        no = mid

print((yes + 9)//10*10)

0