結果
問題 | No.2179 Planet Traveler |
ユーザー | tassei903 |
提出日時 | 2023-01-06 23:12:07 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,329 bytes |
コンパイル時間 | 203 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 85,148 KB |
最終ジャッジ日時 | 2024-11-30 19:55:28 |
合計ジャッジ時間 | 58,417 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
60,416 KB |
testcase_01 | AC | 40 ms
62,916 KB |
testcase_02 | AC | 41 ms
62,384 KB |
testcase_03 | AC | 39 ms
59,904 KB |
testcase_04 | AC | 50 ms
63,428 KB |
testcase_05 | AC | 41 ms
60,416 KB |
testcase_06 | AC | 41 ms
63,960 KB |
testcase_07 | AC | 68 ms
81,792 KB |
testcase_08 | AC | 133 ms
84,384 KB |
testcase_09 | AC | 133 ms
82,688 KB |
testcase_10 | AC | 121 ms
84,344 KB |
testcase_11 | AC | 447 ms
82,432 KB |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | AC | 377 ms
84,484 KB |
testcase_15 | AC | 388 ms
83,200 KB |
testcase_16 | AC | 394 ms
84,204 KB |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | AC | 1,293 ms
85,148 KB |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | AC | 1,353 ms
77,568 KB |
testcase_28 | TLE | - |
testcase_29 | TLE | - |
ソースコード
import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### from collections import defaultdict 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 all_group_members(self): group_members = defaultdict(list) for member in range(self.n): group_members[self.find(member)].append(member) return group_members def __str__(self): return '\n'.join(f'{r}: {m}' for r, m in self.all_group_members().items()) n = ni() x,y,t = zip(*[na() for i in range(n)]) ok = 10**18 ng = -1 while ok - ng > 1: d = ok+ng>>1 uf = UnionFind(n) for i in range(n): for j in range(i+1, n): if t[i] == t[j]: if (x[i]-x[j])**2+(y[i]-y[j])**2 <= d: uf.union(i, j) else: d1, d2 = min(x[i]**2+y[i]**2,x[j]**2+y[j]**2),max(x[i]**2+y[i]**2,x[j]**2+y[j]**2) #print(d1,d2) if (d1 + d2 - d)**2 <= 4 * d1 *d2 or d1 + d2 - d <= 0: uf.union(i, j) #print(d, uf.all_group_members()) if uf.same(0, n-1): ok = d else: ng = d print(ok)