class UnionFind: def __init__(self, n): self.n=n self.parent_size=[-1]*n def merge(self, a, b): x, y=self.leader(a), self.leader(b) if x == y: return if abs(self.parent_size[x])1: mid=(ok+ng)//2 if check(mid): ok=mid else: ng=mid print(ok)