結果

問題 No.94 圏外です。(EASY)
ユーザー 👑 rin204rin204
提出日時 2022-07-09 15:06:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 5,000 ms
コード長 1,792 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 78,852 KB
最終ジャッジ日時 2023-08-29 22:06:08
合計ジャッジ時間 4,490 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,868 KB
testcase_01 AC 68 ms
71,284 KB
testcase_02 AC 68 ms
71,792 KB
testcase_03 AC 69 ms
71,280 KB
testcase_04 AC 91 ms
76,436 KB
testcase_05 AC 94 ms
77,164 KB
testcase_06 AC 101 ms
78,108 KB
testcase_07 AC 111 ms
78,696 KB
testcase_08 AC 121 ms
78,824 KB
testcase_09 AC 138 ms
78,784 KB
testcase_10 AC 147 ms
78,776 KB
testcase_11 AC 135 ms
78,756 KB
testcase_12 AC 133 ms
78,328 KB
testcase_13 AC 134 ms
78,408 KB
testcase_14 AC 138 ms
78,852 KB
testcase_15 AC 141 ms
78,440 KB
testcase_16 AC 138 ms
78,324 KB
testcase_17 AC 141 ms
78,692 KB
testcase_18 AC 138 ms
78,512 KB
testcase_19 AC 169 ms
78,648 KB
testcase_20 AC 69 ms
71,788 KB
testcase_21 AC 69 ms
71,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.group = n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        self.group -= 1
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return self.group

    def all_group_members(self):
        dic = {r:[] for r in self.roots()}
        for i in range(self.n):
            dic[self.find(i)].append(i)
        return dic

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n = int(input())
if n == 0:
    print(1)
    exit()
xy = [list(map(int, input().split())) for _ in range(n)]
UF = UnionFind(n)
for i in range(n):
    for j in range(i + 1, n):
        dx = xy[j][0] - xy[i][0]
        dy = xy[j][1] - xy[i][1]
        if dx * dx + dy * dy <= 100:
            UF.union(i, j)
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        if UF.same(i, j):
            dx = xy[j][0] - xy[i][0]
            dy = xy[j][1] - xy[i][1]
            ans = max(ans, (dx * dx + dy * dy) ** 0.5)
print(ans + 2)
0