Cow allocation (stall4.pas/in. out)
Description
Farmer John just built his new cowshed last week and he used the latest milking technology. Unfortunately, due to engineering problems, each bull bar is different. In the first week, Farmer John casually moved the cows into the barrier, but the problem was quickly revealed: every cow only wishes to produce milk in the barrier they liked. Last week, Farmer John just collected information about the interests of the cows (which columns of each cow like to produce milk ). A bullpen can only accommodate one cow. Of course, a cow can only produce milk in one column.
Provide information about the interests of the cows and calculate the maximum allocation scheme.
Input Format
The first line has two integers: n (0 <= n <= 200) and M (0 <= m <= 200 ). N is the number of cows of Farmer John and m is the number of cows in the new cowshed.
From the second row to the nth + 1 row, there are n rows in total, each row corresponds to a cow. The first number (SI) is the number of columns (0 <= SI <= m) in which the cow is willing to produce milk ). The number of SI Numbers that follow indicates the numbers of these columns. The number of the bull's column is limited to the interval (1. m). In the same row, a bull's column will not be listed twice.
Output Format
Only one row. Output an integer that indicates the maximum number of columns that can be allocated.
Sample input 5 5 2 2 5 3 3 4 2 1 5 3 1 2 5 1 2
Sample output 4
A bipartite graph refers to a graph in which all vertices can be divided into two sets X and Y. Any two vertices in X or Y in the same set are not connected, all edges are associated with two vertices. Exactly one belongs to set X and the other belongs to set Y. Given a bipartite graph G, M is a subset of the G edge set. If M satisfies the condition that any two edges are not attached to the same vertex, M is a match. The matching with the largest number of edges in the graph is called the maximum matching of the graph.
There is another Binary Graph and network stream type.
Http://blog.csdn.net/juncoder/article/details/38340447
Binary match + network stream unfinished