結果

問題 No.2179 Planet Traveler
ユーザー ntudantuda
提出日時 2023-01-26 22:13:36
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 944 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 128,296 KB
最終ジャッジ日時 2023-09-09 20:34:05
合計ジャッジ時間 19,686 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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