|
|
вернуться в форумI got TimeLimited!Help! Послано zealot 1 апр 2003 14:36 Here is my program: program conference; const max=1000; var map:array[1..max,1..max] of boolean; link:array[1..max] of longint; cover:array[1..max] of boolean; n,m,k:longint; procedure readdata; var i,j,a,b:longint; begin readln(n,m,k); for i:=1 to k do begin readln(a,b); map[a][b]:=true; end; end; function find(i:longint):boolean; var k,p:longint; begin find:=true; for k:=1 to m do if map[i][k] and not cover[k] then begin p:=link[k];link[k]:=i;cover[k]:=true; if (p=0) or find(p) then exit; link[k]:=p; end; find:=false; end; procedure main; var x:longint; begin for x:=1 to n do begin fillchar(cover,sizeof(cover),0); find(x); end; end; procedure print; var i,j,step:longint; begin step:=0; for i:=1 to m do if link[i]<>0 then inc(step); writeln(n+m-step); end; BEGIN readdata; main; print; END. |
|
|