Always search for whether there is a wrong link in the bipartite graph. If yes, increase the number of matches by 1.
The link starts at the left and ends at the left. The path length is an odd number, and the first and last line segments do not match. In this way, if there is a wrong link, there must be another match that is 1 longer than the original one.
Flag indicates whether the current vertex has been accessed, and link indicates the precursor of the vertex after the link is handed in the wrong link.
Bool source [110] [310], flag [310];
Int _ link [310], p, N;
Bool find (int)
{
Int I, J, K;
For (I = 1; I <= N; I ++)
{
If (source [a] [I] = 1 & flag [I] = 0)
{
Flag [I] = 1;
If (_ link [I] = 0 | find (_ link [I])
{
_ Link [I] =;
Return true;
}
}
}
Return false;
}
Int main ()
{
Input Source; mount = 0;
For (I = 1; I <= P; I ++)
{
Memset (flag, 0, sizeof (FLAG ));
If (find (I) Mount ++;
}
Cout <Mount <Endl;
}