結果
| 問題 |
No.2179 Planet Traveler
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2023-01-06 23:27:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 340 ms / 3,000 ms |
| コード長 | 1,632 bytes |
| コンパイル時間 | 328 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 71,936 KB |
| 最終ジャッジ日時 | 2024-11-30 20:20:05 |
| 合計ジャッジ時間 | 4,546 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
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)
mkawa2