結果

問題 No.94 圏外です。(EASY)
ユーザー roarisroaris
提出日時 2019-10-27 10:39:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 174 ms / 5,000 ms
コード長 1,351 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 86,780 KB
実行使用メモリ 78,532 KB
最終ジャッジ日時 2023-10-12 22:50:08
合計ジャッジ時間 4,374 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,268 KB
testcase_01 AC 74 ms
71,308 KB
testcase_02 AC 74 ms
71,692 KB
testcase_03 AC 76 ms
70,960 KB
testcase_04 AC 93 ms
76,420 KB
testcase_05 AC 101 ms
76,756 KB
testcase_06 AC 108 ms
77,756 KB
testcase_07 AC 117 ms
78,004 KB
testcase_08 AC 125 ms
77,936 KB
testcase_09 AC 147 ms
77,852 KB
testcase_10 AC 150 ms
78,256 KB
testcase_11 AC 145 ms
78,280 KB
testcase_12 AC 149 ms
78,120 KB
testcase_13 AC 147 ms
77,736 KB
testcase_14 AC 152 ms
78,044 KB
testcase_15 AC 149 ms
78,160 KB
testcase_16 AC 151 ms
78,508 KB
testcase_17 AC 152 ms
78,184 KB
testcase_18 AC 150 ms
78,532 KB
testcase_19 AC 174 ms
77,672 KB
testcase_20 AC 75 ms
71,828 KB
testcase_21 AC 74 ms
71,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Unionfind:
    def __init__(self, n):
        self.par = [-1] * n
        self.rank = [1] * n
    
    def root(self, x):
        if self.par[x] < 0:
            return x
        
        self.par[x] = self.root(self.par[x])
        
        return self.par[x]
    
    def unite(self, x, y):
        rx, ry = self.root(x), self.root(y)
        
        if rx != ry:
            if self.rank[rx] >= self.rank[ry]:
                self.par[rx] += self.par[ry]
                self.par[ry] = rx
                
                if self.par[rx] == self.par[ry]:
                    self.rank[rx] += 1
            else:
                self.par[ry] += self.par[rx]
                self.par[rx] = ry
    
    def is_same(self, x, y):
        return self.root(x) == self.root(y)
    
    def count(self, x):
        return -self.par[x]

N = int(input())

if N == 0:
    print(1)
    exit()
    
XY = [tuple(map(int, input().split())) for _ in range(N)]
uf = Unionfind(N)

for i in range(N):
    for j in range(i+1, N):
        Xi, Yi = XY[i]
        Xj, Yj = XY[j]
        
        if (Xj-Xi)**2+(Yj-Yi)**2 <=100:
            uf.unite(i, j)

ans = 2

for i in range(N):
    for j in range(i+1, N):
        if uf.is_same(i, j):
            Xi, Yi = XY[i]
            Xj, Yj = XY[j]
            ans = max(ans, ((Xj-Xi)**2+(Yj-Yi)**2)**0.5+2)

print(ans)
0