結果

問題 No.2179 Planet Traveler
ユーザー ntudantuda
提出日時 2023-01-26 22:14:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,344 ms / 3,000 ms
コード長 945 bytes
コンパイル時間 1,473 ms
コンパイル使用メモリ 86,772 KB
実行使用メモリ 128,552 KB
最終ジャッジ日時 2023-09-09 20:35:06
合計ジャッジ時間 21,270 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,832 KB
testcase_01 AC 74 ms
71,740 KB
testcase_02 AC 75 ms
71,680 KB
testcase_03 AC 75 ms
71,876 KB
testcase_04 AC 76 ms
71,528 KB
testcase_05 AC 76 ms
71,780 KB
testcase_06 AC 75 ms
71,552 KB
testcase_07 AC 76 ms
71,660 KB
testcase_08 AC 86 ms
76,028 KB
testcase_09 AC 88 ms
76,560 KB
testcase_10 AC 92 ms
76,416 KB
testcase_11 AC 705 ms
103,588 KB
testcase_12 AC 349 ms
117,380 KB
testcase_13 AC 551 ms
118,892 KB
testcase_14 AC 421 ms
102,700 KB
testcase_15 AC 379 ms
102,044 KB
testcase_16 AC 429 ms
102,800 KB
testcase_17 AC 2,005 ms
128,212 KB
testcase_18 AC 1,117 ms
121,920 KB
testcase_19 AC 2,344 ms
128,552 KB
testcase_20 AC 185 ms
83,760 KB
testcase_21 AC 910 ms
117,100 KB
testcase_22 AC 585 ms
104,312 KB
testcase_23 AC 863 ms
102,596 KB
testcase_24 AC 1,537 ms
116,128 KB
testcase_25 AC 594 ms
106,032 KB
testcase_26 AC 1,844 ms
120,604 KB
testcase_27 AC 202 ms
83,696 KB
testcase_28 AC 606 ms
98,168 KB
testcase_29 AC 1,959 ms
118,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import ceil
from heapq import *
#import time
#st = time.time()

N = int(input())
RXYT = []
for i in range(N):
    x, y, t = map(int, input().split())
    r = (x ** 2 + y ** 2) ** 0.5
    RXYT.append((r, x, y, t))

E = [[] for _ in range(N)]
for i in range(N - 1):
    r1, x1, y1, t1 = RXYT[i]
    for j in range(i + 1, N):
        r2, x2, y2, t2 = RXYT[j]
        if t1 == t2:
            tmp = (x1 - x2) ** 2 + (y1 - y2) ** 2
            E[i].append((j, tmp))
            E[j].append((i, tmp))
        else:
            tmp = (r1 - r2) ** 2
            E[i].append((j, tmp))
            E[j].append((i, tmp))

D = [float('inf')] * N
D[0] = 0
q = [(0, 0)]
while len(q) > 0:
    d, u = heappop(q)
    for i in E[u]:
        a, b = i
        if d > D[u]: continue
        tmp = max(D[u], b)
        if D[a] > tmp:
            D[a] = tmp
            heappush(q, (D[a], a))
#print(D)
print(ceil(round(D[N - 1],8)))
#print(time.time() - st)
0