QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#3480. 公交规划

Statistics

一个小学班级正乘巴士前往一家计算机工厂进行实地考察。然而,司机实在厌倦了整天驾驶时还要处理打架的孩子,因此她建议班级应该分成若干小组前往工厂。她已经观察出哪些孩子互相讨厌并可能打架,所以她想确保这些孩子不会被分在同一个小组。当然,让每个人单独乘车既浪费时间又浪费金钱,因此司机希望尽量减少她需要驾驶的小组数量。此外,巴士空间有限,一次最多只能容纳 $c$ 个孩子。

你需要编写一个程序来帮助她完成分组任务。给定孩子的数量和他们的敌对关系,求出所需的最少小组数量,以及将班级划分为该最少数量小组的方案。

图片由 AutoPhoto 提供,来自 Wikimedia Commons,采用 cc 协议

输入格式

第一行包含三个整数 $n$、$k$ 和 $c$ ($1 \le n \le 17$,$0 \le k \le \frac{n(n-1)}{2}$,$1 \le c \le n$),分别代表孩子的数量、敌对关系的对数以及巴士的容量。接下来 $n$ 行包含孩子们的名字。每个名字仅由字符 A-Z 和 a-z 组成,非空,且长度不超过 10 个字符。随后 $k$ 行,每行包含一对以空格分隔的名字,表示一对互相讨厌的孩子。没有一对名字会出现两次,且没有孩子会与自己为敌。

输出格式

第一行输出最少的小组数量,随后每行输出一个小组中包含的孩子名字(以空格分隔)。

样例

样例输入 1

2 0 1
Alice
Bob

样例输出 1

2
Alice
Bob

样例输入 2

3 2 3
Alice
Charlie
Bob
Alice Charlie
Bob Charlie

样例输出 2

2
Alice Bob
Charlie

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.