Calvinball Championship, Again 2
Time limit1sMemory limit256 MB
Split n players into the fewest teams so no pair who dislike each other shares a team.
- Level
Hard9 of 10
- Topics
- Graph, Backtracking, Brute force
- Solved
- No attempts yet
Problem
A Calvinball game has players. Some pairs dislike each other (symmetrically). Split everyone into teams so no disliking pair shares a team, using as few teams as possible. Output any optimal division.
Input
Line 1: and , the player count and dislike-pair count. Next lines: distinct players and who dislike each other ().
Output
Line 1: team count . Next lines list players on each team in any order. Teams and players within a team may appear in any order.
Note
Batch data may be judged separately; the sample above is a normal stdin/stdout case.