The problem asks for maximum matching in a bipartite graph where boys are group , girls are group , 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.