結果

問題 No.2179 Planet Traveler
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2022-09-26 17:38:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 775 ms / 3,000 ms
コード長 879 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 87,376 KB
実行使用メモリ 198,028 KB
最終ジャッジ日時 2023-08-20 13:59:16
合計ジャッジ時間 10,637 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,652 KB
testcase_01 AC 74 ms
71,448 KB
testcase_02 AC 75 ms
71,568 KB
testcase_03 AC 74 ms
71,572 KB
testcase_04 AC 73 ms
71,464 KB
testcase_05 AC 72 ms
71,128 KB
testcase_06 AC 72 ms
71,420 KB
testcase_07 AC 80 ms
76,348 KB
testcase_08 AC 113 ms
77,744 KB
testcase_09 AC 112 ms
77,628 KB
testcase_10 AC 106 ms
77,264 KB
testcase_11 AC 547 ms
182,188 KB
testcase_12 AC 775 ms
198,028 KB
testcase_13 AC 506 ms
133,000 KB
testcase_14 AC 303 ms
107,148 KB
testcase_15 AC 301 ms
105,680 KB
testcase_16 AC 288 ms
105,416 KB
testcase_17 AC 535 ms
141,068 KB
testcase_18 AC 515 ms
144,464 KB
testcase_19 AC 579 ms
143,112 KB
testcase_20 AC 183 ms
79,772 KB
testcase_21 AC 506 ms
136,796 KB
testcase_22 AC 370 ms
113,112 KB
testcase_23 AC 327 ms
104,072 KB
testcase_24 AC 458 ms
124,660 KB
testcase_25 AC 394 ms
111,588 KB
testcase_26 AC 520 ms
126,852 KB
testcase_27 AC 182 ms
79,808 KB
testcase_28 AC 302 ms
93,816 KB
testcase_29 AC 499 ms
126,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #



n=int(input())
x=[0]
y=[0]
t=[0]
for i in range(n):
    a,b,c=map(int,input().split())
    x.append(a)
    y.append(b)
    t.append(c)
def dist2(i,j,s):
    if t[i]==t[j]:
        return (x[i]-x[j])**2+(y[i]-y[j])**2<=s
    ri2=x[i]**2+y[i]**2
    rj2=x[j]**2+y[j]**2
    if ri2+rj2-s<0:return True
    return (ri2+rj2-s)**2<=4*ri2*rj2

def f(s):
    if s<0:return -1
    root=[[] for i in range(n+3)]
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            if dist2(i,j,s):
                root[i].append(j)
                root[j].append(i)
    seen=[0]*(n+3)
    seen[1]=1
    data=[1]
    while data:
        now=data.pop()
        for to in root[now]:
            if seen[to]:continue
            seen[to]=1
            data.append(to)
    return seen[n]
ng=-1
ok=10**10
while ok-ng>1:
    mid=(ok+ng)//2
    if f(mid):ok=mid
    else:ng=mid
print(ok)



0