結果

問題 No.168 ものさし
ユーザー takakintakakin
提出日時 2020-06-15 22:02:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 870 ms / 2,000 ms
コード長 896 bytes
コンパイル時間 69 ms
コンパイル使用メモリ 11,028 KB
実行使用メモリ 74,416 KB
最終ジャッジ日時 2023-09-16 10:35:39
合計ジャッジ時間 7,502 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 208 ms
22,716 KB
testcase_01 AC 16 ms
8,548 KB
testcase_02 AC 16 ms
8,128 KB
testcase_03 AC 16 ms
8,552 KB
testcase_04 AC 16 ms
8,648 KB
testcase_05 AC 15 ms
8,644 KB
testcase_06 AC 15 ms
8,592 KB
testcase_07 AC 16 ms
8,576 KB
testcase_08 AC 15 ms
8,584 KB
testcase_09 AC 21 ms
8,720 KB
testcase_10 AC 36 ms
9,892 KB
testcase_11 AC 183 ms
21,280 KB
testcase_12 AC 594 ms
54,248 KB
testcase_13 AC 833 ms
74,316 KB
testcase_14 AC 828 ms
74,292 KB
testcase_15 AC 16 ms
8,696 KB
testcase_16 AC 19 ms
8,760 KB
testcase_17 AC 27 ms
9,028 KB
testcase_18 AC 55 ms
10,988 KB
testcase_19 AC 820 ms
71,668 KB
testcase_20 AC 853 ms
74,348 KB
testcase_21 AC 870 ms
74,308 KB
testcase_22 AC 852 ms
74,416 KB
権限があれば一括ダウンロードができます

ソースコード

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=[]

def f(x1,y1,x2,y2):
  dist2=(x2-x1)**2+(y2-y1)**2
  dist=int(dist2**0.5)
  while dist**2<dist2:
    dist+=1
  return ((dist-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