[Delphi]
Program p1_2;
Const
Maxn = 200;
Var
N, m, l, I, j, k, ans, x, y: longint;
B: array [1 .. 400] of boolean;
Map: array [1 .. 400, 1 .. 400] of boolean;
A: array [1 .. 400] of longint;
Function find (x: longint): boolean;
Var
I, j: longint;
Begin
For I: = 1 to m do
If not (B [I]) and (map [x, I]) then
Begin
B [I]: = true;
If a [I] = 0 then begin a [I]: = x; exit (true); end;
If find (a [I]) then begin a [I]: = x; exit (true); end;
End;
Exit (false );
End;
Begin
I: = 1;
Read (n, m, l );
While (n + m + l> 0) do
Begin
Ans: = 0;
Fillchar (a, sizeof (a), 0 );
Fillchar (map, sizeof (map), true );
For k: = 1 to l do
Begin
Read (x, y );
Map [x, y]: = false;
End;
For k: = 1 to n do
Begin
Fillchar (B, sizeof (B), false );
If find (k) then inc (ans );
End;
Writeln ('case', I, ':', n + m-ans );
Inc (I );
Read (n, m, l );
End;
End.
Hungarian algorithm: www.2cto.com
B [] indicates whether the current point for finding the staggered P has been connected. a [] indicates the point before a certain point.
The two points graph in this question is the largest group (each point is connected to each other). The two points graph can be regarded as the largest independent set of the supplementary graph (each point is not connected to each other )......