結果

問題 No.94 圏外です。(EASY)
ユーザー nebukuro09nebukuro09
提出日時 2016-10-12 13:12:26
言語 Python2
(2.7.18)
結果
AC  
実行時間 545 ms / 5,000 ms
コード長 1,422 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 6,680 KB
実行使用メモリ 27,152 KB
最終ジャッジ日時 2023-09-08 15:01:12
合計ジャッジ時間 6,686 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,036 KB
testcase_01 AC 11 ms
6,240 KB
testcase_02 AC 12 ms
6,132 KB
testcase_03 AC 12 ms
6,040 KB
testcase_04 AC 17 ms
6,420 KB
testcase_05 AC 29 ms
7,140 KB
testcase_06 AC 57 ms
8,716 KB
testcase_07 AC 110 ms
11,424 KB
testcase_08 AC 214 ms
16,956 KB
testcase_09 AC 418 ms
26,980 KB
testcase_10 AC 421 ms
26,984 KB
testcase_11 AC 417 ms
27,084 KB
testcase_12 AC 425 ms
26,968 KB
testcase_13 AC 417 ms
27,004 KB
testcase_14 AC 423 ms
27,116 KB
testcase_15 AC 422 ms
27,032 KB
testcase_16 AC 437 ms
26,940 KB
testcase_17 AC 433 ms
27,048 KB
testcase_18 AC 434 ms
27,048 KB
testcase_19 AC 545 ms
27,152 KB
testcase_20 AC 12 ms
6,128 KB
testcase_21 AC 12 ms
6,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

class UnionFind(object):
    def __init__(self, n):
        self.uf = [-1 for _ in xrange(n)]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.uf[x] >= self.uf[y]:
            self.uf[y] += self.uf[x]
            self.uf[x] = y
        else:
            self.uf[x] += self.uf[y]
            self.uf[y] = x

    def find(self, x):
        leaves = []
        while self.uf[x] >= 0:
            leaves.append(x)
            x = self.uf[x]
        for lf in leaves:
            self.uf[lf] = x
        return x

    def get_unions(self):
        unions = {}
        for i in xrange(N):
            root = self.find(i)
            if root in unions:
                unions[root].append(i)
            else:
                unions[root] = [i]
        return unions
    
N = input()
p = [map(int, raw_input().split()) for _ in xrange(N)]

if N == 0:
    print 1
    exit()

uf = UnionFind(N)
dist = [[0 for j in xrange(N)] for i in xrange(N)]
for i in xrange(N):
    for j in xrange(i+1, N):
        d = (p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2 
        if d <= 100:
            uf.union(i, j)
        dist[i][j] = d
        dist[j][i] = d

m = 0
for union in uf.get_unions().values():
    for i in xrange(len(union)):
        for j in xrange(i+1, len(union)):
            m = max(m, dist[union[i]][union[j]])
print math.sqrt(m)+2
0