結果

問題 No.94 圏外です。(EASY)
ユーザー matsu7874matsu7874
提出日時 2015-11-29 20:57:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,579 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 37,348 KB
最終ジャッジ日時 2023-10-12 05:53:15
合計ジャッジ時間 16,966 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,692 KB
testcase_01 WA -
testcase_02 AC 17 ms
8,480 KB
testcase_03 AC 17 ms
8,324 KB
testcase_04 AC 26 ms
8,628 KB
testcase_05 AC 43 ms
9,592 KB
testcase_06 AC 88 ms
11,480 KB
testcase_07 AC 181 ms
14,860 KB
testcase_08 AC 356 ms
21,236 KB
testcase_09 AC 847 ms
32,948 KB
testcase_10 AC 864 ms
32,936 KB
testcase_11 AC 751 ms
32,924 KB
testcase_12 AC 858 ms
32,928 KB
testcase_13 AC 806 ms
32,968 KB
testcase_14 AC 990 ms
32,944 KB
testcase_15 AC 882 ms
32,880 KB
testcase_16 AC 1,005 ms
32,900 KB
testcase_17 AC 950 ms
32,908 KB
testcase_18 AC 826 ms
33,052 KB
testcase_19 TLE -
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 count_groups(self):
        cnt = 0
        for t in self.table:
            if t > -1:
                cnt += 1
        return cnt

    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())
P = []
for i in range(N):
    x, y = map(int, input().split())
    P.append((y, x))
uf = UnionFind(N)
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)
max_len = 1
for i in range(N - 1):
    for j in range(i + 1, N):
        if uf.find(i) == uf.find(j):
            max_len = max(max_len, dist[i][j]**0.5+2)
print(max_len)
0