There are two machines A and B, with N and M processes respectively, and K tasks. Each task is either completed on the X PROCESS OF, it is either completed in the y process of B, but it takes time for the machine to change the process.
Minimum coverage,
Generic: There are two solutions, which act as the vertices of the Bipartite Graph. When the task is a vertex, the two solutions of each task are connected to the edge and the maximum matching is required, because "minimum coverage = maximum matching"
What is the I in the input ??
View code
1 program pku1325(input,output);
2 var
3 f : array[0..201,0..201] of boolean;
4 lk : array[0..201] of longint;
5 v : array[0..201] of boolean;
6 n,m,k : longint;
7 procedure init;
8 var
9 i,ii,xx,yy : longint;
10 begin
11 fillchar(f,sizeof(f),false);
12 fillchar(lk,sizeof(lk),0);
13 for i:=1 to k do
14 begin
15 readln(ii,xx,yy);
16 f[xx,yy+n]:=true;
17 end;
18 end; { init }
19 function find(now : longint):boolean;
20 var
21 i : longint;
22 begin
23 for i:=n+1 to n+m do
24 if (not v[i])and(f[now,i]) then
25 begin
26 v[i]:=true;
27 if (lk[i]=0)or(find(lk[i])) then
28 begin
29 lk[i]:=now;
30 exit(true);
31 end;
32 end;
33 exit(false);
34 end; { find }
35 function main():longint;
36 var
37 i : longint;
38 begin
39 main:=0;
40 for i:=1 to n do
41 begin
42 fillchar(v,sizeof(v),false);
43 if find(i) then
44 inc(main);
45 end;
46 exit(main);
47 end; { main }
48 begin
49 read(n);
50 while n<>0 do
51 begin
52 readln(m,k);
53 init;
54 writeln(main);
55 read(n);
56 end;
57 end.