結果

問題 No.2179 Planet Traveler
ユーザー MasKoaTSMasKoaTS
提出日時 2022-09-06 18:50:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,062 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 107,648 KB
最終ジャッジ日時 2024-05-07 20:26:22
合計ジャッジ時間 5,126 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,352 KB
testcase_01 AC 38 ms
52,864 KB
testcase_02 AC 40 ms
52,992 KB
testcase_03 WA -
testcase_04 AC 42 ms
52,864 KB
testcase_05 AC 40 ms
52,608 KB
testcase_06 WA -
testcase_07 AC 37 ms
52,992 KB
testcase_08 AC 45 ms
60,032 KB
testcase_09 AC 54 ms
62,336 KB
testcase_10 AC 51 ms
59,776 KB
testcase_11 AC 129 ms
97,920 KB
testcase_12 AC 175 ms
107,520 KB
testcase_13 AC 185 ms
107,392 KB
testcase_14 AC 153 ms
98,944 KB
testcase_15 AC 198 ms
99,072 KB
testcase_16 AC 165 ms
98,944 KB
testcase_17 AC 208 ms
107,520 KB
testcase_18 AC 297 ms
107,648 KB
testcase_19 AC 190 ms
107,520 KB
testcase_20 AC 98 ms
78,848 KB
testcase_21 AC 309 ms
104,320 KB
testcase_22 AC 171 ms
91,520 KB
testcase_23 AC 134 ms
88,704 KB
testcase_24 AC 182 ms
99,968 KB
testcase_25 AC 134 ms
91,392 KB
testcase_26 AC 165 ms
100,736 KB
testcase_27 AC 82 ms
78,848 KB
testcase_28 AC 120 ms
86,528 KB
testcase_29 AC 208 ms
99,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, math
from heapq import heappop, heappush
input = sys.stdin.readline

def isqrt(n):
	rn = math.sqrt(n)
	ok = max(0, int(rn - 2))
	ng = int(rn + 2)
	while(ng - ok > 1):
		k = (ok + ng) >> 1
		if(k * k <= n):
			ok = k
		else:
			ng = k
	return ok


"""
Main Code
"""

n = int(input())
planet = [list(map(int, input().split())) for _ in [0] * n]

route = [[] for _ in [0] * n]
for i in range(0, n-1):
	for j in range(i+1, n):
		p1 = planet[i]
		p2 = planet[j]
		d = (p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2
		if(p1[2] != p2[2]):
			r1 = p1[0] ** 2 + p1[1] ** 2
			r2 = p2[0] ** 2 + p2[1] ** 2
			d = r1 + r2 - isqrt(4 * r1 * r2)
		route[i].append((j, d))
		route[j].append((i, d))

def check(mid):
	stk = [0]
	visited = [False] * n
	while(stk):
		v = stk.pop()
		if(v == n - 1):
			return True
		for nv, nd in route[v]:
			if(visited[nv] or nd > mid):
				continue
			visited[nv] = True
			stk.append(nv)
	return False

ok = 10 ** 9
ng = -1
while(ok - ng > 1):
	mid = (ok + ng) >> 1
	if(check(mid)):
		ok = mid
	else:
		ng = mid

ans = ok
print(ans)
0