結果

問題 No.94 圏外です。(EASY)
ユーザー momotaros300momotaros300
提出日時 2019-09-07 16:50:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 166 ms / 5,000 ms
コード長 1,169 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 78,616 KB
最終ジャッジ日時 2023-09-09 04:49:43
合計ジャッジ時間 4,377 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,948 KB
testcase_01 AC 73 ms
71,600 KB
testcase_02 AC 73 ms
71,688 KB
testcase_03 AC 71 ms
71,392 KB
testcase_04 AC 97 ms
76,760 KB
testcase_05 AC 107 ms
77,764 KB
testcase_06 AC 117 ms
78,136 KB
testcase_07 AC 127 ms
78,000 KB
testcase_08 AC 144 ms
78,124 KB
testcase_09 AC 160 ms
78,304 KB
testcase_10 AC 161 ms
78,104 KB
testcase_11 AC 162 ms
78,616 KB
testcase_12 AC 162 ms
78,232 KB
testcase_13 AC 160 ms
78,380 KB
testcase_14 AC 162 ms
78,072 KB
testcase_15 AC 160 ms
78,036 KB
testcase_16 AC 162 ms
78,572 KB
testcase_17 AC 166 ms
78,316 KB
testcase_18 AC 162 ms
78,252 KB
testcase_19 AC 144 ms
78,220 KB
testcase_20 AC 76 ms
71,708 KB
testcase_21 AC 74 ms
71,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
ans=0
if n==0:
    print(1)
    exit()

class UnionFind:
    __slots__ = ['id']

    def __init__(self, n):
        self.id = [-1] * n

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

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

    def union(self, x, y):
        s1, s2 = self.root(x), self.root(y)
        if s1 != s2:
            if self.id[s1] <= self.id[s2]:
                self.id[s1] += self.id[s2]
                self.id[s2] = s1
            else:
                self.id[s2] += self.id[s1]
                self.id[s1] = s2
            return True
        return False

uf =UnionFind(n)
for i in range(n):
    for j in range(n):
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        if (x1-x2)**2+(y1-y2)**2<=100:
            uf.union(i,j)


for i in range(n):
    for j in range(n):
        if uf.find(i,j):
            x1,y1=xy[i]
            x2,y2=xy[j]
            ans=max(ans,(x1-x2)**2+(y1-y2)**2)

print(ans**(0.5)+2)

                

0