Types
WeightedUnionFind[T] = ref object count*: int par_or_siz: seq[int] potential_diff: seq[T]
- Source Edit
Procs
proc diff[T](self: WeightedUnionFind[T]; x, y: int): T
- Source Edit
proc initWeightedUnionFind(N: int; potential_type: typedesc = int): WeightedUnionFind[ potential_type]
- Source Edit
proc issame[T](self: WeightedUnionFind[T]; x: int; y: int): bool
- Source Edit
proc potential[T](self: WeightedUnionFind[T]; x: int): T
- Source Edit
proc root[T](self: WeightedUnionFind[T]; x: int): int
- Source Edit
proc siz[T](self: WeightedUnionFind[T]; x: int): int
- Source Edit
proc unite[T](self: WeightedUnionFind[T]; x: int; y: int; w: T): bool
- potential[y]-potential[x] = wとなるように辺を張ります 正しく辺が張れるならば、true,そうでないならばfalseを返します Source Edit