結果

問題 No.168 ものさし
ユーザー mkawa2mkawa2
提出日時 2020-05-16 15:33:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,376 ms / 2,000 ms
コード長 1,439 bytes
コンパイル時間 1,455 ms
コンパイル使用メモリ 11,972 KB
実行使用メモリ 152,296 KB
最終ジャッジ日時 2023-10-23 15:52:02
合計ジャッジ時間 11,082 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 269 ms
42,308 KB
testcase_01 AC 30 ms
10,540 KB
testcase_02 AC 31 ms
10,540 KB
testcase_03 AC 30 ms
10,488 KB
testcase_04 AC 30 ms
10,488 KB
testcase_05 AC 29 ms
10,540 KB
testcase_06 AC 31 ms
10,484 KB
testcase_07 AC 29 ms
10,540 KB
testcase_08 AC 31 ms
10,540 KB
testcase_09 AC 34 ms
11,252 KB
testcase_10 AC 51 ms
13,716 KB
testcase_11 AC 249 ms
38,572 KB
testcase_12 AC 936 ms
109,220 KB
testcase_13 AC 1,376 ms
150,404 KB
testcase_14 AC 560 ms
113,076 KB
testcase_15 AC 29 ms
10,536 KB
testcase_16 AC 34 ms
11,060 KB
testcase_17 AC 41 ms
12,364 KB
testcase_18 AC 64 ms
16,860 KB
testcase_19 AC 1,325 ms
148,236 KB
testcase_20 AC 773 ms
129,236 KB
testcase_21 AC 1,319 ms
152,296 KB
testcase_22 AC 802 ms
131,056 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