#K53007. Taco Group Division
Taco Group Division
Taco Group Division
You are given n participants, a list of m conflicting pairs, and a maximum group size g. Your task is to partition the participants into the minimum number of groups such that no two participants who dislike each other (as given by the conflicting pairs) end up in the same group. Note that each group can contain at most g participants.
The input starts with three integers: n, m, and g. Then follow n lines of participant names, and m lines each containing two names representing a conflicting pair.
The output should first contain the minimum number of groups, followed by the groups themselves (one group per line, with names separated by a single space).
Note: When displaying any mathematical formulas, use LaTeX format. For example, use $n$
to represent the number of participants.
inputFormat
The first line contains three integers: n m g
, where:
n
is the number of participants.m
is the number of conflicting pairs.g
is the maximum number of participants allowed in any group.
The next n
lines each contain a participant name.
The following m
lines each contain two participant names separated by a space, indicating that these two participants should not be in the same group.
outputFormat
Output the minimum number of groups on the first line.
Then, for each group, output a line containing the participant names in that group separated by a space.
## sample4 2 2
John
Jane
Alice
Bob
John Jane
Alice Bob
2
John Alice
Jane Bob
</p>