Graph Theory37 sections · 1633 units
Open in Course

School Dance - Core Idea

(Bipartite matching directly)

The problem asks for maximum matching in a bipartite graph where boys are group LL, girls are group RR, and edges represent pairs willing to dance. You will build an adjacency list for each boy listing which girls he can dance with.

Then run Kuhn's algorithm: for each boy, try to find an augmenting path using DFS. The size of the final matching is your answer. Reconstruct the matched pairs from the match[] array.