讨论 / 2
wuzw 2011-11-05 00:21:00
点我顶贴 收藏 删除
type r=^shu;

shu=record

x:array[0..1000]of integer;

end;

const

a='a';b='b';c='c';d='d';

var s,s1,s2:r;

n,t1,i,m,t2,li:integer;

l:array[1..2000]of char;bl:boolean;

procedure work(var i:integer;si,sj:r;var ti,tj:integer;xj,yj:char);

begin

repeat

if (i>n)or(bl) then exit;

if (s^.x[i]<si^.x[ti])or(si^.x[ti]=m) then

begin

repeat if si^.x[ti]=m then//

begin

inc(li);l[li]:=yj;dec(ti);inc(m);

end;

until si^.x[ti]<>m;

if (s^.x[i]<si^.x[ti]) then //

begin

inc(ti);si^.x[ti]:=s^.x[i];inc(li);l[li]:=xj;

bl:=true;end

else

end

else

if (s^.x[i]<sj^.x[tj])or(sj^.x[tj]=m) then work(i,sj,si,tj,ti,c,d)

else begin writeln('0');halt;end;

until bl;

inc(i);bl:=false;

work(i,s1,s2,t1,t2,a,b);

end;

begin

new(s);new(s1);new(s2);

m:=1;

s1^.x[0]:=maxint; s2^.x[0]:=maxint;

readln(n);

for i:=1 to n do read(s^.x[i]);

i:=1;

work(i,s1,s2,t1,t2,a,b);

for i:=1 to n+n-2 do write(l[i],' ');//

if l[n+n-1]<>'' then write(l[n+n-1],' ') else write('d',' ');//

writeln(l[n+n]);

readln ;readln

end.

查看更多回复
提交回复