- 排座椅
- 2009-07-06 17:09:11 @
大牛指点……
var
a,b,c,d:array[1..1000] of integer;
m,n,k,l,db,i,j,x,y,p,q,t:integer;
begin
read(m,n,k,l,db);
for i:=1 to db do
begin
read(x,y,p,q);
if x-p=1 then a[p]:=a[p]+1;
if p-x=1 then a[x]:=a[x]+1;
if y-q=1 then b[q]:=b[q]+1;
if q-y=1 then b[y]:=b[y]+1;
end;
for i:=1 to m do
c[i]:=i;
for j:=1 to n do
d[j]:=j;
for i:=1 to m-1 do
for j:=m downto i+1 do
if a[j]>a[j-1] then
begin
t:=a[j];
a[j]:=a[j-1];
a[j-1]:=t;
t:=c[j];
c[j]:=c[j-1];
c[j-1]:=t;
end;
for i:=1 to n-1 do
for j:=n downto i+1 do
if b[j]>b[j-1] then
begin
t:=b[j];
b[j]:=b[j-1];
b[j-1]:=t;
t:=d[j];
d[j]:=d[j-1];
d[j-1]:=t;
end;
p:=1;
q:=1;
while a[p]0 do inc(p);
while b[q]0 do inc(q);
p:=p-1;
q:=q-1;
if k>p then k:=p;
if k>=1 then
begin
write(c[1]);
for i:=2 to k do
write(' ',c[i]);
writeln;
end;
if l>q then l:=q;
if l>=1 then
begin
write(d[1]);
for j:=2 to l do
write(' ',d[j]);
end;
{writeln;
for i:=1 to m do
writeln(i,' ',a[i],' ',c[i]);
for j:=1 to n do
writeln(j,' ',b[j],' ',d[j]);}
end.
1 条评论
-
gsrq LV 10 @ 2009-07-08 12:13:49
顺序
输出顺序必须从小到大
牢记题目要求
- 1