結果

問題 No.94 圏外です。(EASY)
ユーザー momotaros300momotaros300
提出日時 2019-09-07 16:32:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,316 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 88,632 KB
最終ジャッジ日時 2023-09-09 04:27:43
合計ジャッジ時間 4,071 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,636 KB
testcase_01 AC 77 ms
71,488 KB
testcase_02 AC 79 ms
76,068 KB
testcase_03 AC 74 ms
71,116 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 RE -
testcase_20 WA -
testcase_21 AC 74 ms
71,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
data=[[-1]*(10**3) for i in range(10**3)]
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):
    x,y=xy[i]
    data[x][y]=i

for k in range(n):
    x,y=xy[k]
    for i in range(-10,11):
        for j in range(-10,11):
            if data[i][j]>=0:
                if (x-i)**2+(y-j)**2<=100:
                    uf.union(k,data[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