結果
問題 | No.2179 Planet Traveler |
ユーザー | MasKoaTS |
提出日時 | 2022-11-30 16:43:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 671 ms / 3,000 ms |
コード長 | 1,566 bytes |
コンパイル時間 | 387 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 133,040 KB |
最終ジャッジ日時 | 2024-05-07 20:29:54 |
合計ジャッジ時間 | 10,983 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 119 ms
86,016 KB |
testcase_01 | AC | 121 ms
86,144 KB |
testcase_02 | AC | 121 ms
86,144 KB |
testcase_03 | AC | 121 ms
86,400 KB |
testcase_04 | AC | 123 ms
86,144 KB |
testcase_05 | AC | 122 ms
86,144 KB |
testcase_06 | AC | 123 ms
86,016 KB |
testcase_07 | AC | 123 ms
86,528 KB |
testcase_08 | AC | 138 ms
88,576 KB |
testcase_09 | AC | 139 ms
88,704 KB |
testcase_10 | AC | 133 ms
88,448 KB |
testcase_11 | AC | 213 ms
111,872 KB |
testcase_12 | AC | 636 ms
126,772 KB |
testcase_13 | AC | 671 ms
127,360 KB |
testcase_14 | AC | 229 ms
112,768 KB |
testcase_15 | AC | 230 ms
112,384 KB |
testcase_16 | AC | 227 ms
113,024 KB |
testcase_17 | AC | 595 ms
133,040 KB |
testcase_18 | AC | 506 ms
128,384 KB |
testcase_19 | AC | 517 ms
130,304 KB |
testcase_20 | AC | 224 ms
92,032 KB |
testcase_21 | AC | 596 ms
126,384 KB |
testcase_22 | AC | 372 ms
111,872 KB |
testcase_23 | AC | 319 ms
106,112 KB |
testcase_24 | AC | 518 ms
123,136 KB |
testcase_25 | AC | 369 ms
111,360 KB |
testcase_26 | AC | 488 ms
122,240 KB |
testcase_27 | AC | 208 ms
92,640 KB |
testcase_28 | AC | 299 ms
102,276 KB |
testcase_29 | AC | 591 ms
125,992 KB |
ソースコード
import itertools as iter import collections as coll import heapq as hq import bisect as bis from decimal import Decimal as dec from functools import cmp_to_key import math import sys #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') sys.setrecursionlimit(10 ** 6) inp = sys.stdin.readline input = lambda : inp().rstrip() getN = lambda : int(inp()) getNs = lambda : map(int, inp().split()) getList = lambda :list(map(int, inp().split())) getStrs = lambda n : [input() for _ in [0] * n] def yexit(): print("Yes"); exit(0) def nexit(): print("No"); exit(0) pi = 3.141592653589793 mod = 1000000007 MOD = 998244353 INF = 4611686018427387903 dx = [1, 0, -1, 0]; dy = [0, 1, 0, -1] #di = coll.defaultdict(int) """ Main Code """ n = getN() planet = [getList() for _ in [0]*n] def isqrt(n): ok = 0 ng = n + 1 while(ng - ok > 1): mid = (ok + ng) >> 1 if(mid * mid <= n): ok = mid else: ng = mid return ok route = [[] for _ in [0]*n] for i in range(n-1): for j in range(i+1, n): p1 = planet[i] p2 = planet[j] dist = (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 dist = r1 + r2 - isqrt(4 * r1 * r2) route[i].append((j,dist)) route[j].append((i,dist)) dp = [10 ** 18] * n dp[0] = 0 que = [(0, 0)] while(que): d_now, v_now = hq.heappop(que) if(v_now == n-1): print(d_now) exit(0) for v_next, dist in route[v_now]: d_next = max(d_now, dist) if(d_next >= dp[v_next]): continue dp[v_next] = d_next hq.heappush(que, (d_next, v_next))