結果

問題 No.2179 Planet Traveler
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-01-07 00:10:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 591 ms / 3,000 ms
コード長 982 bytes
コンパイル時間 969 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 97,592 KB
最終ジャッジ日時 2023-08-20 17:41:13
合計ジャッジ時間 9,317 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,620 KB
testcase_01 AC 71 ms
71,308 KB
testcase_02 AC 62 ms
71,584 KB
testcase_03 AC 63 ms
71,300 KB
testcase_04 AC 79 ms
71,556 KB
testcase_05 AC 63 ms
71,620 KB
testcase_06 AC 64 ms
71,272 KB
testcase_07 AC 79 ms
71,700 KB
testcase_08 AC 89 ms
76,288 KB
testcase_09 AC 74 ms
76,592 KB
testcase_10 AC 74 ms
76,548 KB
testcase_11 AC 187 ms
85,848 KB
testcase_12 AC 212 ms
84,256 KB
testcase_13 AC 241 ms
85,520 KB
testcase_14 AC 179 ms
85,536 KB
testcase_15 AC 173 ms
85,188 KB
testcase_16 AC 188 ms
85,856 KB
testcase_17 AC 591 ms
97,592 KB
testcase_18 AC 315 ms
90,092 KB
testcase_19 AC 565 ms
97,180 KB
testcase_20 AC 157 ms
80,428 KB
testcase_21 AC 304 ms
88,284 KB
testcase_22 AC 237 ms
85,448 KB
testcase_23 AC 298 ms
87,316 KB
testcase_24 AC 397 ms
91,792 KB
testcase_25 AC 246 ms
85,540 KB
testcase_26 AC 496 ms
95,072 KB
testcase_27 AC 148 ms
79,744 KB
testcase_28 AC 249 ms
84,832 KB
testcase_29 AC 508 ms
94,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop,heappush
def isqrt(n):
    rn = int(n**0.5)
    l = max(0, rn - 1)
    r = int(rn + 2)
    while r > l+1:
        m = (r+l)//2
        if m*m <= n:
            l = m
        else:
            r = m
    return l

n = int(input())
XYT = [list(map(int,input().split())) for i in range(n)]

inf = 10**20

dist = [[0]*n for i in range(n)]
for i in range(n):
    for j in range(i):
        x,y,t = XYT[i]
        nx,ny,nt = XYT[j]
        if t == nt:
            d = (x-nx)**2+(y-ny)**2
            
        else:
            r1 = (x**2+y**2)
            r2 = (nx**2+ny**2)

            d = r1+r2 - isqrt(4*r1*r2)
        dist[i][j] = dist[j][i] = d

dis = [inf]*n

dis[0] = 0
h = [[0,0]]

while h:
    d,now = heappop(h)
    if dis[now] != d:
        continue
    for j in range(n):
        if now == j:
            continue
        dnex = max(d,dist[now][j])
        if dis[j] > dnex:
            dis[j] = dnex
            heappush(h,[dnex,j])
print(dis[-1])

0