GEARS - Editorial

What do the pair of vectors inside the groups array indicate?

I simply created a graph and ran BFS from the source to color the graph. If on coloring from source it did’nt get colored , it was disconnected . And color gave the info about the sign . Can Someone give me the tricky test cases where my code is failing ?
My solution : https://www.codechef.com/viewsolution/19229385

For this specific kind of disjoint set union , read this article https://cp-algorithms.com/data_structures/disjoint_set_union.html