結果
| 問題 |
No.168 ものさし
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2020-01-26 10:42:32 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,543 ms / 2,000 ms |
| コード長 | 1,439 bytes |
| コンパイル時間 | 303 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 152,960 KB |
| 最終ジャッジ日時 | 2024-09-14 10:54:12 |
| 合計ジャッジ時間 | 10,941 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
import sys
sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *
import math
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]
def main():
def cald(d):
s=max(math.ceil(d**0.5)//10*10-20,0)
for x in range(s,s+100,10):
if x**2>=d:return x
n=II()
xy=[]
to=defaultdict(list)
for i in range(n):
x0,y0=MI()
for j,(x,y) in enumerate(xy):
d=(x0-x)**2+(y0-y)**2
to[i].append((j,d))
to[j].append((i,d))
xy.append((x0,y0))
fin=[False]*n
hp=[]
heappush(hp,[0,0])
while hp:
d,i=heappop(hp)
if i==n-1:
print(cald(d))
exit()
if fin[i]:continue
fin[i]=True
for j,c in to[i]:
if fin[j]:continue
heappush(hp,[max(d,c),j])
main()
mkawa2