Problem D
Bus Planning
You are to write a program which helps her with the task of making these groups. Given the number of kids and their enemies, find the minimum number of groups required, as well as a division of the class into this minimum number of groups
Input
The first line contains three integers $n$, $k$, and $c$ ($1 \le n \le 17$, $0 \le k \le \frac{n(n-1)}{2}$ and $1 \le c \le n$) – the number of kids, pairs of enemies, and the capacity of the bus, respectively. Then follow $n$ lines with the kids’ names. Each name consists solely of the characters A-Z and a-z, is non-empty, and at most $10$ characters long. Then follow $k$ lines, each containing a pair of space-separated names indicating a pair of kids that dislike each other. No pair of names appears twice, and no kid is their own enemy.
Output
On the first line, output the minimum number of groups, followed by one line per group containing the names of the children in that group (separated by spaces).
Sample Input 1 | Sample Output 1 |
---|---|
2 0 1 Alice Bob |
2 Alice Bob |
Sample Input 2 | Sample Output 2 |
---|---|
3 2 3 Alice Charlie Bob Alice Charlie Bob Charlie |
2 Alice Bob Charlie |