結果

問題 No.168 ものさし
ユーザー gigurururugigurururu
提出日時 2015-03-26 00:16:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 138,748 KB
最終ジャッジ日時 2023-08-25 20:54:27
合計ジャッジ時間 4,884 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 172 ms
90,360 KB
testcase_01 AC 72 ms
71,416 KB
testcase_02 AC 74 ms
71,280 KB
testcase_03 AC 73 ms
71,180 KB
testcase_04 AC 72 ms
71,448 KB
testcase_05 AC 75 ms
71,416 KB
testcase_06 AC 73 ms
71,416 KB
testcase_07 AC 73 ms
71,444 KB
testcase_08 AC 73 ms
71,444 KB
testcase_09 AC 93 ms
76,524 KB
testcase_10 AC 101 ms
78,188 KB
testcase_11 AC 161 ms
89,144 KB
testcase_12 AC 217 ms
109,040 KB
testcase_13 AC 310 ms
134,636 KB
testcase_14 AC 167 ms
109,940 KB
testcase_15 AC 74 ms
71,476 KB
testcase_16 AC 94 ms
76,392 KB
testcase_17 AC 105 ms
77,880 KB
testcase_18 AC 103 ms
79,152 KB
testcase_19 AC 240 ms
120,436 KB
testcase_20 AC 206 ms
116,188 KB
testcase_21 AC 321 ms
138,748 KB
testcase_22 AC 233 ms
121,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq,math

def hypot2(x,y):
  return x*x+y*y

def solve(n,l):
  dst=[[(hypot2(x1-x2,y1-y2),j)for j,(x2,y2) in enumerate(l)] for x1,y1 in l]
  visited = set()
  pq = [(0,0)]
  mx=10
  while len(pq):
    my,d = heapq.heappop(pq)
    if(mx<my):mx=my
    if(d==n-1):break
    if(d in visited):continue
    visited.add(d)
    for s,i in dst[d]:
      if(i in visited):continue
      heapq.heappush(pq,(s,i))
  ans=int(math.sqrt(mx))//10*10
  return(ans+10 if ans*ans<mx else ans)

n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
print(solve(n,l))
0