讨论 / 为什么都是运行错误 普通保护错误 486题球看
2013new 2013-10-19 22:20:00
点我顶贴 收藏 删除
var a,b:array[0..100000,1..2] of longint;

i,j,k,l,q,w,e,n,m,x,y,z,s1,s2:longint;

function min(xx,yy:longint):longint;

begin

if xx>yy then exit(yy) else exit(xx);

end;

procedure qsorta(l,r:longint);

var i,j,mix,miy,e:longint;

begin

i:=l;j:=r;mix:=random(r-l+1)+l;miy:=a[mix,2];mix:=a[mix,1];

repeat

while (a[i,1]>mix)or((a[i,1]=mix)and(a[i,2]<miy)) do inc(i);

while (a[j,1]<mix)or((a[i,1]=mix)and(a[i,2]>miy)) do dec(j);

if i<=j then begin e:=a[i,1];a[i,1]:=a[j,1];a[j,1]:=e;e:=a[i,2];

a[i,2]:=a[j,2];a[j,2]:=e;inc(i);dec(j);end;

until i>j;

if i<r then qsorta(i,r);

if j>l then qsorta(l,j);

end;

procedure qsortb(l,r:longint);

var i,j,mix,miy,e:longint;

begin

i:=l;j:=r;mix:=random(r-l+1)+l;miy:=b[mix,2];mix:=b[mix,1];

repeat

while (b[i,1]>mix)or((b[i,1]=mix)and(b[i,2]<miy)) do inc(i);

while (b[j,1]<mix)or((b[j,1]=mix)and(b[j,2]>miy)) do dec(j);

if i<=j then begin e:=b[i,1];b[i,1]:=b[j,1];b[j,1]:=e;e:=b[i,2];

b[i,2]:=b[j,2];b[j,2]:=e;inc(i);dec(j);end;

until i>j;

if i<r then qsortb(i,r);

if j>l then qsortb(l,j);

end;

begin

readln(n,m,x,y,z);

for i:=1 to n+m-min(n,m) do begin a[i,2]:=i;b[i,2]:=i;end;

for i:=1 to z do

begin

readln(k,l,q,w);

if k=q then inc(b[min(l,w),1]) else inc(a[min(k,q),1]);

end;

qsorta(1,n);

qsortb(1,m);

for i:=1 to x do write(a[i,2],' ');writeln;

for i:=1 to y do write(b[i,2],' ');

end.

#1 董阴@2014-02-03 12:22:32
回复 删除
行尾有空格

查看更多回复
提交回复