hdu2458 题目链接
Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1382 Accepted Submission(s): 733
In a kindergarten, there are a lot of kids. All girls of the kids know each other and all boys also know each other. In addition to that, some girls and boys know each other. Now the teachers want to pick some kids to play a game, which need that all players know each other. You are to help to find maximum number of kids the teacher can pick.
The input consists of multiple test cases. Each test case starts with a line containing three integers G, B (1 ≤ G, B ≤ 200) and M (0 ≤ M ≤ G × B), which is the number of girls, the number of boys and the number of pairs of girl and boy who know each other, respectively. Each of the following M lines contains two integers X and Y (1 ≤ X≤ G,1 ≤ Y ≤ B), which indicates that girl X and boy Y know each other. The girls are numbered from 1 to G and the boys are numbered from 1 to B.
The last test case is followed by a line containing three zeros.
For each test case, print a line containing the test case number( beginning with 1) followed by a integer which is the maximum number of kids the teacher can pick.
2 3 3 1 1 1 2 2 3 2 3 5 1 1 1 2 2 1 2 2 2 3 0 0 0
Case 1: 3 Case 2: 4
2008 Asia Hefei Regional Contest Online by USTC
这题是说老师要带小朋友做游戏,男孩之间相互全部认识,女孩之间全部相互认识。现在要选一些人来做游戏,要求选取的人必须全部互相认识的,问最多选取多少人。
这里必须要求所有人全部都相互认识,正向考虑的话就比较麻烦了。然后我的想法就是不认识的人的关系定为0.求一个最大的匹配数,就表示这些匹配的人之间相互不认识,求出不认识的人的最大匹配数,然后拿总人数减去这些人之后其他的就是全部互相两两认识了。
二分匹配模板
