結果
問題 | No.2179 Planet Traveler |
ユーザー | 👑 H20 |
提出日時 | 2023-01-06 23:02:49 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,012 bytes |
コンパイル時間 | 378 ms |
コンパイル使用メモリ | 87,212 KB |
実行使用メモリ | 175,000 KB |
最終ジャッジ日時 | 2023-08-20 16:30:17 |
合計ジャッジ時間 | 13,538 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 241 ms
91,804 KB |
testcase_01 | AC | 242 ms
91,688 KB |
testcase_02 | AC | 239 ms
91,548 KB |
testcase_03 | AC | 242 ms
91,616 KB |
testcase_04 | AC | 238 ms
91,560 KB |
testcase_05 | AC | 241 ms
91,776 KB |
testcase_06 | AC | 240 ms
91,612 KB |
testcase_07 | AC | 263 ms
93,092 KB |
testcase_08 | AC | 485 ms
97,452 KB |
testcase_09 | AC | 411 ms
96,040 KB |
testcase_10 | AC | 441 ms
96,524 KB |
testcase_11 | AC | 1,717 ms
147,572 KB |
testcase_12 | AC | 1,923 ms
150,308 KB |
testcase_13 | AC | 2,679 ms
158,652 KB |
testcase_14 | AC | 1,975 ms
157,316 KB |
testcase_15 | AC | 1,926 ms
155,824 KB |
testcase_16 | AC | 1,892 ms
154,732 KB |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | AC | 1,157 ms
111,132 KB |
testcase_21 | AC | 2,819 ms
169,112 KB |
testcase_22 | AC | 2,167 ms
145,864 KB |
testcase_23 | AC | 2,085 ms
140,352 KB |
testcase_24 | AC | 2,728 ms
158,728 KB |
testcase_25 | AC | 2,249 ms
144,732 KB |
testcase_26 | AC | 2,784 ms
161,488 KB |
testcase_27 | AC | 1,324 ms
114,012 KB |
testcase_28 | AC | 1,923 ms
129,812 KB |
testcase_29 | AC | 2,728 ms
159,008 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 size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def __str__(self): return '\n'.join(f'{r}: {m}' for r, m in self.all_group_members().items()) 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 IJD[i*N+j]<=hs: uf.union(i,j) return uf.same(0,N-1) 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')) IJD = [0]*(N**2) for i in range(N): for j in range(i+1,N): IJD[i*N+j]=abs(D[i]-D[j]) ng = -1 ok = 3200000001 while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid print(ok)