What did this problem teach you?
Many problems are bipartite detection in disguise. "Can you split into two groups where X?" often means bipartite.
You might need to build the graph first. Convert edge lists to adjacency lists.
Watch for -indexing. Adjust array sizes and loop bounds so.
The core BFS/coloring logic stays the same.
Only the setup changes. Pattern recognition is the skill here. Once you see "bipartite," the solution is mechanical.