Graph Theory37 sections · 1633 units
Open in Course

CSES 1668 Building Teams - Core Idea

Same algo, new output

The detection algorithm is identical. The only difference is what you do after: run bipartite detection with BFS. If you find a conflict, print "IMPOSSIBLE". If no conflict, the color array already contains the partition,print it.

You do not need to compute anything extra. The color array is the answer. You have been building it all along. Translate color 00 to team 11 and color 11 to team 22 when printing the output.