結果

問題 No.168 ものさし
ユーザー takakintakakin
提出日時 2020-06-15 21:53:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 850 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 11,100 KB
実行使用メモリ 74,488 KB
最終ジャッジ日時 2023-09-16 10:34:59
合計ジャッジ時間 7,758 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
8,280 KB
testcase_02 AC 15 ms
8,492 KB
testcase_03 AC 15 ms
8,640 KB
testcase_04 AC 15 ms
8,628 KB
testcase_05 WA -
testcase_06 AC 15 ms
8,576 KB
testcase_07 AC 15 ms
8,564 KB
testcase_08 WA -
testcase_09 AC 21 ms
8,876 KB
testcase_10 AC 34 ms
9,972 KB
testcase_11 AC 163 ms
21,396 KB
testcase_12 AC 539 ms
54,280 KB
testcase_13 WA -
testcase_14 AC 752 ms
74,264 KB
testcase_15 AC 16 ms
8,532 KB
testcase_16 AC 19 ms
8,748 KB
testcase_17 AC 26 ms
9,276 KB
testcase_18 AC 51 ms
10,936 KB
testcase_19 AC 744 ms
71,644 KB
testcase_20 AC 778 ms
74,260 KB
testcase_21 AC 782 ms
74,384 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,heapq
input = sys.stdin.buffer.readline
n=int(input())

par=[-1]*n

def find(x):
  if par[x]<0:
    return x
  else:
    par[x]=find(par[x])
    return par[x]

def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return False
  else:
    if par[x]>par[y]:
      x,y=y,x
    par[x]+=par[y]
    par[y]=x
    return True

def same(x,y):
  return find(x)==find(y)

def size(x):
  return -par[find(x)]

import heapq
XY=[]
for _ in range(n):
  XY.append(tuple(int(i) for i in input().split()))
Q=[]
eps=0.0001
def f(x1,y1,x2,y2):
  return ((int(((x2-x1)**2+(y2-y1)**2)**0.5+eps)-1)//10+1)*10
for i in range(n-1):
  for j in range(i+1,n):
    heapq.heappush(Q,(f(XY[i][0],XY[i][1],XY[j][0],XY[j][1]),i,j))
ans=0
while True:
  d,i,j=heapq.heappop(Q)
  if not same(i,j):
    ans=max(ans,d)
    unite(i,j)
  if same(0,n-1):
    break
print(ans)


0