結果

問題 No.94 圏外です。(EASY)
ユーザー nebukuro09nebukuro09
提出日時 2016-10-12 12:59:57
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 1,407 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 7,328 KB
実行使用メモリ 15,872 KB
最終ジャッジ日時 2024-05-01 20:19:32
合計ジャッジ時間 6,960 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,528 KB
testcase_01 WA -
testcase_02 AC 9 ms
6,400 KB
testcase_03 AC 9 ms
6,528 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 10 ms
6,272 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 <= 1000:
            uf.union(i, j)
            dist[i][j] = 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, max(dist[i][j], dist[j][i]))
print math.sqrt(m)+2
0