| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
谁能告诉我程序哪里不对,小妹将以身相许初学几天,请gg多多指教!
const maxn =50;
var sd :array[1..maxn,1..4]of integer;
p :array[1..maxn,1..2]of integer;
mp :array[1..maxn,1..maxn]of boolean;
cvr :array[1..maxn]of boolean;
lnk :array[1..maxn]of integer;
n,stp :integer;
procedure read_in;
var i:integer;
begin
readln(n); if n=0 then halt;
for i:=1 to n do readln(sd[i,1],sd[i,2],sd[i,3],sd[i,4]);
for i:=1 to n do readln(p[i,1],p[i,2]);
end;
function btw(a,i,j:integer):boolean;
begin
btw:=(i<a) and (a<j);
end;
procedure build_graph;
var i,j:integer;
begin
fillchar(mp,sizeof(mp),0);
for i:=1 to n do
for j:=1 to n do
mp[i,j]:=btw(p[i,1],sd[j,1],sd[j,2]) and btw(p[i,2],sd[j,3],sd[j,4])
end;
function find(k:integer):boolean;
var i,q:integer;
begin
find:=true;
for i:=1 to n do if mp[k,i] and not cvr[i] then begin
cvr[i]:=true;
q:=lnk[i]; lnk[i]:=k;
if (q=0) or find(q) then exit;
lnk[i]:=q;
end;
find:=false;
end;
procedure max_match;
var i,q,w:integer;
begin
fillchar(lnk,sizeof(lnk),0);
for i:=1 to n do begin
fillchar(cvr,sizeof(cvr),0);
find(i);
end;
inc(stp);
writeln('Heap ',stp);
w:=0;
for i:=1 to n do begin
q:=lnk[i]; lnk[i]:=0;
mp[q,i]:=false;
fillchar(cvr,sizeof(cvr),0);
if not find(q) then begin
lnk[i]:=q;
inc(w); if w>1 then write(' ');
write('(',chr(i+64),',',lnk[i],')');
end;
mp[q,i]:=true;
end;
if w=0 then write('none');
writeln;
end;
begin
stp:=0;
repeat
read_in;
build_graph;
max_match;
writeln;
until false;
end.
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator