当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1081:You Who?

题目描述
On the first day of first grade at Friendly Elementrary School, it is customary for each student to spend one minute talking to every classmate that he or she does not already know. When student Bob sees an unfamilar face, he says ``You who?'' A typical response is ``Me Charlie, you who?'' Then Bob says, ``Me Bob!'' and they talk for a minute. It's very cute. Then, after a minute, they part and each looks for another stranger to greet. This takes time. In class of twenty-nine or thirty mutual strangers, it takes 29 minutes; time that, according to teachers, could be better spent learning the alphabet. Of course, it is rare to have a first grade class where nobody knows anyone else; there are neighbors and playmates who already know each other, so they don't have to go through the get-to-know-you minutes with each other.
The two first grade teachers have requested that, to save time, students be allocated to their two classes so that the difference in the sizes of the classes is at most one, and the time it takes to complete these introductions is as small as possible. There are no more than 60 students in the incoming first grade class.

How can the assignment of students to classes be made? Your job is to write the software that answers the question.

输入解释
The school records include information about these student friendships, represented as lists of numbers. If there are 29 students, then they are represented by the numbers 1 to 29. The record for a single student includes, first, his/her student identification number (1 to 29, in this example), then the number of his/her acquaintances, then a list of them in no particular order. So, for example, this record
17 4 5 2 14 22

indicates that student 17 knows 4 students: 5, 2, and so on. The records for all the students in the incoming class are represented as the list of numbers that results from concatenating all the student records together. Spaces and line breaks are irrelevent in this format. Thus, this

1 1 2 2 1 1

is a whole database, indicating that there are only two students in the incoming class, and they know each other; and this

1 2 3 4
2 2 3 4
3 2 1 2
4 2 1 2

indicates that 1 doesn't know 2, and 3 doesn't know 4, but all other pairs know each other.

The database has been checked for consistency, so that if A knows B, then B knows A.
输出解释
Your output should begin with a number that tells how long it will take to complete the introductions in the best possible legal class assignment. For the simple two student problem above, the only legal answer is

0
输入样例
1 2 3 4 
2 2 3 4 
3 2 1 2 
4 2 1 2 
输出样例
0
提示
To make this problem more tractable, the following changes are being made. There will be exactly two classes. There will be no more that 30 students. The students will be divided as evenly as possible between the classes. The loneliness of a student is the number of students in his class whom he does not know. You are to arrange the classes to minimize the loneliness of the loneliest student. for the sample data ,you can arrange 1 and 3 to the first class,and 2 and 4 to the second class,then they need no time to know each other.

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 South Central USA 1998

源链接: POJ-1081

最后修改于 2020-10-29T05:51:56+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000