|
|
вернуться в форумCould anyone help me? Послано SunCat 27 фев 2003 17:52 program Ural_1109; type tnode=^node; node=record y:integer; next:tnode; end; const maxn=1000; var g:array[1..maxn] of tnode; cover:array[1..maxn] of boolean; link:array[1..maxn] of integer; n,m:integer; can:boolean; procedure init; var i,t,a,b:integer; p:tnode; begin fillchar(g,sizeof(g),0); fillchar(cover,sizeof(cover),0); fillchar(link,sizeof(link),0); readln(m,n,t); for i:=1 to t do begin readln(a,b); new(p); p^.y:=b;p^.next:=nil; if g[a]<>nil then begin p^.next:=g[a]; g[a]:=p; end else g[a]:=p; end; end; procedure find(i:integer); var j,q,k:integer; p:tnode; begin if cover[i] then exit; cover[i]:=true; p:=g[i]; while p<>nil do begin j:=p^.y; q:=link[j]; if (q=0) then can:=true else find(q); if can then begin link[j]:=i; exit; end; p:=p^.next; end; end; procedure main; var i,tmatch:integer; begin for i:=1 to m do begin fillchar(cover,sizeof(cover),0); can:=false; find(i); end; tmatch:=0; for i:=1 to n do if link[i]<>0 then inc(tmatch); writeln(m+n-tmatch); end; begin { assign(input,'input.txt');reset(input);} init; { close(input);} main; end. |
|
|