結果

問題 No.94 圏外です。(EASY)
ユーザー pluto77pluto77
提出日時 2019-11-16 10:52:31
言語 Python2
(2.7.18)
結果
AC  
実行時間 2,217 ms / 5,000 ms
コード長 1,008 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 7,132 KB
実行使用メモリ 6,724 KB
最終ジャッジ日時 2023-10-25 03:49:48
合計ジャッジ時間 19,127 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,540 KB
testcase_01 AC 12 ms
6,416 KB
testcase_02 AC 12 ms
6,540 KB
testcase_03 AC 11 ms
6,356 KB
testcase_04 AC 28 ms
6,544 KB
testcase_05 AC 64 ms
6,552 KB
testcase_06 AC 153 ms
6,568 KB
testcase_07 AC 341 ms
6,600 KB
testcase_08 AC 718 ms
6,648 KB
testcase_09 AC 1,434 ms
6,708 KB
testcase_10 AC 1,424 ms
6,708 KB
testcase_11 AC 1,393 ms
6,708 KB
testcase_12 AC 1,442 ms
6,708 KB
testcase_13 AC 1,425 ms
6,708 KB
testcase_14 AC 1,460 ms
6,708 KB
testcase_15 AC 1,433 ms
6,708 KB
testcase_16 AC 1,452 ms
6,708 KB
testcase_17 AC 1,457 ms
6,708 KB
testcase_18 AC 1,448 ms
6,708 KB
testcase_19 AC 2,217 ms
6,724 KB
testcase_20 AC 12 ms
6,540 KB
testcase_21 AC 12 ms
6,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki94
import sys

class Unionfind:
 def __init__(self,N):
  self.par=[-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 find(self,x,y):
  return self.root(x)==self.root(y)

 def unite(self,x,y):
  rx,ry=self.root(x),self.root(y)
        
  if rx!=ry:
   rx_num,ry_num=-self.par[rx],-self.par[ry]
            
   if rx_num>ry_num or (rx_num==ry_num and rx<ry):
    self.par[rx]+=self.par[ry]
    self.par[ry]=rx
   elif ry_num>rx_num or (rx_num==ry_num and ry<rx):
    self.par[ry]+=self.par[rx]
    self.par[rx]=ry

n=int(raw_input())

if n==0:
 print 1
 sys.exit()

uf=Unionfind(n)

l=[]
for i in range(n):
 l.append(map(int,raw_input().split()))

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

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

print 1.0*res**0.5+2
0