結果

問題 No.2179 Planet Traveler
ユーザー 👑 KazunKazun
提出日時 2023-01-06 22:39:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,087 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 98,780 KB
最終ジャッジ日時 2024-05-07 22:19:44
合計ジャッジ時間 6,795 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
86,940 KB
testcase_01 AC 102 ms
80,176 KB
testcase_02 AC 100 ms
80,188 KB
testcase_03 AC 97 ms
79,804 KB
testcase_04 AC 106 ms
80,220 KB
testcase_05 AC 103 ms
80,084 KB
testcase_06 AC 98 ms
80,156 KB
testcase_07 AC 113 ms
81,556 KB
testcase_08 AC 254 ms
82,872 KB
testcase_09 AC 226 ms
82,972 KB
testcase_10 AC 235 ms
82,980 KB
testcase_11 AC 349 ms
89,496 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    from math import sqrt,ceil
    from decimal import Decimal

    N=int(input())

    X=[0]*N; Y=[0]*N; T=[0]*N
    for i in range(N):
        X[i],Y[i],T[i]=map(int,input().split())

    level=[[0]*N for _ in range(N)]
    for i in range(N):
        level_i=level[i]
        for j in range(N):
            if T[i]==T[j]:
                dx=X[i]-X[j]
                dy=Y[i]-Y[j]
                level_i[j]=dx*dx+dy*dy
            else:
                ri=Decimal(sqrt(Decimal(X[i]*X[i]+Y[i]*Y[i])))
                rj=Decimal(sqrt(Decimal(X[j]*X[j]+Y[j]*Y[j])))
                dr=abs(ri-rj)
                level_i[j]=ceil(dr*dr)

    inf=float("inf")
    D=[inf]*N; D[0]=0
    F=[0]*N

    for _ in range(N):
        i=-1
        for p in range(N):
            if F[p]==0 and (i==-1 or D[p]<D[i]):
                i=p

        F[i]=1
        level_i=level[i]
        for j in range(N):
            if F[j]==0 and max(D[i],level_i[j])<D[j]:
                D[j]=max(D[i],level_i[j])

    return D[N-1]

#==================================================
print(solve())
0