結果

問題 No.168 ものさし
ユーザー mkawa2mkawa2
提出日時 2020-01-26 10:42:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,305 ms / 2,000 ms
コード長 1,439 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 10,744 KB
実行使用メモリ 150,784 KB
最終ジャッジ日時 2023-10-12 12:00:35
合計ジャッジ時間 9,349 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 261 ms
40,916 KB
testcase_01 AC 19 ms
9,200 KB
testcase_02 AC 20 ms
9,056 KB
testcase_03 AC 20 ms
9,084 KB
testcase_04 AC 20 ms
9,076 KB
testcase_05 AC 20 ms
9,116 KB
testcase_06 AC 20 ms
9,208 KB
testcase_07 AC 20 ms
9,080 KB
testcase_08 AC 20 ms
9,112 KB
testcase_09 AC 25 ms
9,984 KB
testcase_10 AC 39 ms
12,576 KB
testcase_11 AC 223 ms
37,176 KB
testcase_12 AC 901 ms
107,712 KB
testcase_13 AC 1,305 ms
148,920 KB
testcase_14 AC 518 ms
111,464 KB
testcase_15 AC 20 ms
9,080 KB
testcase_16 AC 23 ms
9,612 KB
testcase_17 AC 30 ms
10,876 KB
testcase_18 AC 53 ms
15,528 KB
testcase_19 AC 1,280 ms
146,748 KB
testcase_20 AC 741 ms
127,576 KB
testcase_21 AC 1,279 ms
150,784 KB
testcase_22 AC 825 ms
129,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()
0