結果

問題 No.94 圏外です。(EASY)
ユーザー matsu7874matsu7874
提出日時 2015-11-29 21:19:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,607 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 9,508 KB
最終ジャッジ日時 2023-10-12 05:55:17
合計ジャッジ時間 9,467 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,088 KB
testcase_01 WA -
testcase_02 AC 17 ms
8,000 KB
testcase_03 AC 17 ms
8,276 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

class UnionFind:

    def __init__(self, size):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.table = [-1 for _ in range(size)]

    def search_group_ids(self):
        ids = []
        for t in self.table:
            if t > -1:
                ids.append(t)
        return ids

    def find(self, x):
        # 集合の代表を求める
        while self.table[x] >= 0:
            x = self.table[x]
        return x

    def union(self, x, y):
        # 併合
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] >= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
        return self.table[s1]

N = int(input())
if N==0:
    print(1)
    exit()
if N==1:
    print(2)
    exit()
uf = UnionFind(N)
P = []
for i in range(N):
    x, y = map(int, input().split())
    P.append((y, x))

dist = [[0 for j in range(N)] for i in range(N)]
for i in range(N - 1):
    for j in range(i + 1, N):
        dy = P[i][0] - P[j][0]
        dx = P[i][1] - P[j][1]
        dist[i][j] = dy * dy + dx * dx
        if dist[i][j] <= 100:
            uf.union(i, j)
group = [[]]*N
for i in range(N):
    group[uf.find(i)].append(i)
max_len = 0
for i in range(N):
    l = len(group[i])
    if l<2:
        continue
    for j in range(l-1):
        for k in range(j+1,l):
            max_len = max(max_len, dist[j][k])
print(max_len**0.5+2)
0