結果

問題 No.2179 Planet Traveler
ユーザー mkawa2mkawa2
提出日時 2023-01-06 23:27:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 313 ms / 3,000 ms
コード長 1,632 bytes
コンパイル時間 2,002 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2023-08-20 16:57:28
合計ジャッジ時間 5,988 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
71,444 KB
testcase_01 AC 59 ms
71,344 KB
testcase_02 AC 59 ms
71,528 KB
testcase_03 AC 60 ms
71,484 KB
testcase_04 AC 59 ms
71,344 KB
testcase_05 AC 62 ms
71,264 KB
testcase_06 AC 60 ms
71,260 KB
testcase_07 AC 61 ms
71,432 KB
testcase_08 AC 63 ms
76,096 KB
testcase_09 AC 70 ms
76,712 KB
testcase_10 AC 64 ms
76,136 KB
testcase_11 AC 68 ms
76,524 KB
testcase_12 AC 73 ms
76,568 KB
testcase_13 AC 73 ms
76,452 KB
testcase_14 AC 175 ms
76,628 KB
testcase_15 AC 260 ms
77,032 KB
testcase_16 AC 231 ms
76,744 KB
testcase_17 AC 148 ms
76,804 KB
testcase_18 AC 313 ms
76,848 KB
testcase_19 AC 96 ms
76,852 KB
testcase_20 AC 81 ms
76,368 KB
testcase_21 AC 304 ms
76,912 KB
testcase_22 AC 102 ms
76,764 KB
testcase_23 AC 88 ms
77,056 KB
testcase_24 AC 146 ms
76,776 KB
testcase_25 AC 85 ms
76,828 KB
testcase_26 AC 100 ms
76,888 KB
testcase_27 AC 79 ms
76,592 KB
testcase_28 AC 92 ms
76,920 KB
testcase_29 AC 157 ms
76,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

def binary_search(l, r, minimize):
    if minimize: l -= 1
    else: r += 1
    while l+1 < r:
        m = (l+r)//2
        if ok(m) ^ minimize: l = m
        else: r = m
    if minimize: return r
    return l

def ok(m):
    def move(i, j):
        x1, y1, t1 = xyt[i]
        x2, y2, t2 = xyt[j]
        if t1 == t2:
            if (x2-x1)**2+(y2-y1)**2 > m: return False
        else:
            R = x1**2+y1**2
            r = x2**2+y2**2
            if R+r-m < 0:return True
            if (R+r-m)**2 > 4*R*r:return False
        return True

    st = [0]
    vis = [0]*n
    vis[0] = 1
    while st:
        i = st.pop()
        for j in range(n):
            if vis[j]: continue
            if not move(i, j): continue
            if j == n-1: return True
            vis[j] = 1
            st.append(j)
    return False

n = II()
xyt = LLI(n)

ans = binary_search(0, 3200000005, True)
print(ans)
0