結果
問題 | No.2179 Planet Traveler |
ユーザー | 👑 H20 |
提出日時 | 2023-01-06 23:06:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,473 ms / 3,000 ms |
コード長 | 1,695 bytes |
コンパイル時間 | 1,909 ms |
コンパイル使用メモリ | 86,616 KB |
実行使用メモリ | 179,188 KB |
最終ジャッジ日時 | 2023-08-20 16:34:33 |
合計ジャッジ時間 | 37,644 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 193 ms
91,600 KB |
testcase_01 | AC | 198 ms
91,468 KB |
testcase_02 | AC | 192 ms
91,424 KB |
testcase_03 | AC | 190 ms
91,684 KB |
testcase_04 | AC | 196 ms
91,408 KB |
testcase_05 | AC | 200 ms
91,676 KB |
testcase_06 | AC | 213 ms
91,424 KB |
testcase_07 | AC | 244 ms
91,784 KB |
testcase_08 | AC | 354 ms
95,656 KB |
testcase_09 | AC | 290 ms
93,156 KB |
testcase_10 | AC | 286 ms
94,012 KB |
testcase_11 | AC | 1,177 ms
151,800 KB |
testcase_12 | AC | 1,229 ms
154,844 KB |
testcase_13 | AC | 1,779 ms
162,636 KB |
testcase_14 | AC | 1,548 ms
159,200 KB |
testcase_15 | AC | 1,563 ms
158,536 KB |
testcase_16 | AC | 1,533 ms
160,152 KB |
testcase_17 | AC | 2,473 ms
172,912 KB |
testcase_18 | AC | 2,274 ms
173,728 KB |
testcase_19 | AC | 2,245 ms
179,188 KB |
testcase_20 | AC | 833 ms
109,108 KB |
testcase_21 | AC | 2,238 ms
173,720 KB |
testcase_22 | AC | 1,626 ms
144,432 KB |
testcase_23 | AC | 1,383 ms
140,100 KB |
testcase_24 | AC | 1,938 ms
158,560 KB |
testcase_25 | AC | 1,538 ms
146,520 KB |
testcase_26 | AC | 1,833 ms
164,660 KB |
testcase_27 | AC | 923 ms
111,720 KB |
testcase_28 | AC | 1,395 ms
129,384 KB |
testcase_29 | AC | 2,159 ms
160,140 KB |
ソースコード
from decimal import Decimal class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def same(self, x, y): return self.find(x) == self.find(y) def is_ok(s): uf = UnionFind(N) hs = Decimal(s)**Decimal('0.5') for i,xyti in enumerate(XYT): for j,xytj in enumerate(XYT[i+1:],start=i+1): if not uf.same(i,j): if xyti[2]==xytj[2]: xi,yi,ti = xyti xj,yj,tj = xytj if (xi-xj)**2+(yi-yj)**2<=s: uf.union(i,j) else: if XY[i][j]<=hs: uf.union(i,j) if uf.same(0,N-1): return True return uf.same(0,N-1) def meguru_bisect(ng, ok): while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok N = int(input()) XYT = [list(map(int, input().split())) for _ in range(N)] D = [] for i in range(N): D.append(Decimal(XYT[i][0]**2+XYT[i][1]**2)**Decimal('0.5')) XY = [[0]*N for _ in range(N)] for i in range(N): for j in range(i+1,N): XY[i][j]=abs(D[i]-D[j]) print(meguru_bisect(-1,3200000001))