We know how DSU(Disjoint Set Union) can be used to find the connectivity between two users. However, I was wondering if it can be used with a Segment Tree.
Let me explain my idea further. Suppose we have $N$ people, numbered from $1$ to $N$. I have a list of input specifying if two people are friends or not. Running a DSU on the data will tell me if any two people are friends or not. Easy and simple up till here. Now, suppose I have some queries of type, ranges provided in the format $[l_1, r_1]$, $[l_2, r_2]$ up-to $[l_k, r_k]$. I need to answer on the union of these ranges if they all are friends or not.
Now what I thought: Using a bottom-up approach on a Segment Tree, I fill the nodes of the tree with either $0$ or $1$ denoting friends or not-friends. But then I thought that for a query like $[1, 3]$ and 1-based indexing on the Segment Tree, my query will pass as $$ and $[2,3]$ on reaching the bottom of the tree. Now $[2,3]$ will directly return as the tree[node] value but the $$ will pass on to my array that I have used for building the tree. Also, the array should contain a relation between $1$ and ($2, 3$) for proper working of the Tree. Here's when I can't really understand as to how to proceed further.
Maybe the entire idea is wrong and it doesn't really need Segment Trees, or maybe requires more than one Segment Trees. Any help here is appreciated.