dance party
Time Limit: 2 Sec Memory Limit: 128 MBSubmissions: 324 Solved: 112
Description
You are organizing a dance party. The party will be attended by n boys and n girls. There will be several rounds of dancing.
In each round, you divide the guests into n dancing pairs. Each guest must be in exactly one pair, and each pair must contain one boy and one girl. Each boy must dance with a different girl in every round. Some boys and girls like each other and some do not. During the party, each boy agrees to dance with at most k girls he doesn't like. Similarly, each girl agrees to dance with at most k boys she doesn't like.
You are given the each pairs of boys and girls who agree to dance with each other .Find out the maximum number of rounds you can organize.
Input
The first line contains a integer t,which means there are t cases followed.
For each case,the first line contain three integer n,m,k ,which means there are n boys and n girls attending the party and m pairs of boys and girls who agree to dance with each other,and each boy or girl agrees to dance with at most k girls or boys he or she doesn't like.At last ,there are m lines with two integers a,b which means boy a and girl b agree to dance with each other.
(0<n<=100,0<m<=n*n,0<k<100,0<a,b<=n)
Output
The output cotains only one integer which means the maximum number of rounds you can organize.
Sample Input
2 2 4 0 1 1 2 2 2 1 1 2 3 7 0 1 1 1 2 1 3 2 1 2 2 3 1 3 3
Sample Output
2 2
HINT
Source
lshmouse
[ Submit][ Status][ Discuss]
本文介绍了一个有趣的算法问题:如何在考虑参与者喜好限制的情况下,最大化舞会的轮数。通过使用网络流和二分查找的技术,文章提供了一种有效的解决方案。
159

被折叠的 条评论
为什么被折叠?



