HDU2063 _ roller coaster (bipartite chart/maximum matching)
Solution report
Question Portal
Question:
Find the maximum number of matching men and women.
Ideas:
Simple maximum matching.
# Include
# Include
# Include
Using namespace std; int k, n, m, mmap [1100] [1100], vis [550], pre [550]; int dfs (int x) {for (int I = 1; I <= n; I ++) {if (! Vis [I] & mmap [x] [I]) {vis [I] = 1; if (pre [I] =-1 | dfs (pre [I]) {pre [I] = x; return 1 ;}} return 0 ;} int main () {int I, j, u, v; while (~ Scanf ("% d", & k) {if (! K) break; memset (pre,-1, sizeof (pre); memset (mmap, 0, sizeof (mmap); scanf ("% d ", & m, & n); for (I = 0; I
Roller coaster
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 10858 Accepted Submission (s): 4782
Problem DescriptionRPG girls went to the playground today and finally got on the coveted roller coaster. However, there are only two seats in each row of the roller coaster, and there is an unwritten rule, that is, every girl must find a boy as a partner and sit with her. However, every girl has her own ideas. For example, Rabbit is only willing to be a partner with XHD or PQK. Grass is only willing to be a partner with linle or LL, princessSnow is willing to be a partner with the water prodigal son or pseudo cool. Considering the funding issue, boss Liu decided to let the partner find a ride on the roller coaster. Other people, hey, just stand and watch it. Smart Acmer, can you help calculate how many combinations can ride on a roller coaster?
The first line of Input data is a three integer K, M, N, indicating the number of possible combinations, the number of girls, and the number of boys. 0
1 <= N and M <= 500. In the next K rows, each row has two numbers, indicating that female Ai is willing to be partner with boys' Bj. The last 0 end input.
Output outputs an integer for each group of data, indicating the maximum number of combinations that can be used on a roller coaster.
Sample Input
6 3 31 11 21 32 12 33 10
Sample Output
3
AuthorPrincessSnow