結果
問題 | No.2179 Planet Traveler |
ユーザー | Navier_Boltzmann |
提出日時 | 2023-01-20 11:36:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 523 ms / 3,000 ms |
コード長 | 2,342 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 82,596 KB |
実行使用メモリ | 83,388 KB |
最終ジャッジ日時 | 2024-06-23 02:08:00 |
合計ジャッジ時間 | 8,841 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
56,576 KB |
testcase_01 | AC | 51 ms
56,704 KB |
testcase_02 | AC | 45 ms
55,936 KB |
testcase_03 | AC | 43 ms
56,064 KB |
testcase_04 | AC | 44 ms
56,064 KB |
testcase_05 | AC | 44 ms
56,192 KB |
testcase_06 | AC | 45 ms
56,704 KB |
testcase_07 | AC | 66 ms
69,120 KB |
testcase_08 | AC | 95 ms
77,440 KB |
testcase_09 | AC | 95 ms
77,184 KB |
testcase_10 | AC | 85 ms
77,056 KB |
testcase_11 | AC | 349 ms
83,200 KB |
testcase_12 | AC | 523 ms
82,816 KB |
testcase_13 | AC | 508 ms
83,328 KB |
testcase_14 | AC | 313 ms
82,944 KB |
testcase_15 | AC | 316 ms
83,200 KB |
testcase_16 | AC | 300 ms
83,152 KB |
testcase_17 | AC | 493 ms
83,388 KB |
testcase_18 | AC | 480 ms
83,196 KB |
testcase_19 | AC | 493 ms
82,816 KB |
testcase_20 | AC | 165 ms
78,720 KB |
testcase_21 | AC | 447 ms
82,432 KB |
testcase_22 | AC | 332 ms
80,768 KB |
testcase_23 | AC | 324 ms
80,512 KB |
testcase_24 | AC | 410 ms
82,324 KB |
testcase_25 | AC | 350 ms
81,152 KB |
testcase_26 | AC | 450 ms
82,688 KB |
testcase_27 | AC | 167 ms
78,464 KB |
testcase_28 | AC | 281 ms
79,872 KB |
testcase_29 | AC | 454 ms
82,452 KB |
ソースコード
from collections import * from itertools import * from functools import * from heapq import * import math,sys input = sys.stdin.readline N = int(input()) dist = [[0]*N for _ in range(N)] XYT = [tuple(map(int,input().split())) for _ in range(N)] def floor_sqrt(n): y = 10**10 def is_smaller(x): if x**2 <= n: return True return False x = 0 while y-x>1: mid = (y+x)//2 if is_smaller(mid): x = mid else: y = mid return x for i in range(N-1): xi,yi,ti = XYT[i] for j in range(i+1,N): xj,yj,tj = XYT[j] if ti==tj: td = (xi-xj)**2 + (yi-yj)**2 else: td = xi**2+yi**2+xj**2+yj**2-floor_sqrt(4*(xi**2+yi**2)*(xj**2+yj**2)) dist[i][j]=td dist[j][i]=td class DSU: def __init__(self, n): self._n = n self.parent_or_size = [-1] * n def merge(self, a, b): assert 0 <= a < self._n assert 0 <= b < self._n x, y = self.leader(a), self.leader(b) if x == y: return x if -self.parent_or_size[x] < -self.parent_or_size[y]: x, y = y, x self.parent_or_size[x] += self.parent_or_size[y] self.parent_or_size[y] = x return x def same(self, a, b): assert 0 <= a < self._n assert 0 <= b < self._n return self.leader(a) == self.leader(b) def leader(self, a): assert 0 <= a < self._n if self.parent_or_size[a] < 0: return a self.parent_or_size[a] = self.leader(self.parent_or_size[a]) return self.parent_or_size[a] def size(self, a): assert 0 <= a < self._n return -self.parent_or_size[self.leader(a)] def groups(self): leader_buf = [self.leader(i) for i in range(self._n)] result = [[] for _ in range(self._n)] for i in range(self._n): result[leader_buf[i]].append(i) return [r for r in result if r != []] def is_ok(s): D = DSU(N) for i in range(N-1): for j in range(i+1,N): if dist[i][j]<=s: D.merge(i,j) return D.same(0,N-1) x = -1 y = 10**18 while y-x>1: mid = (y+x)//2 if is_ok(mid): y = mid else: x = mid print(y)