disjoint set and segment tree