why i am wrong????
Послано
bill 28 сен 2009 20:31
program p1008_image_encoding;
const
ele:array[1..4]of char=('R','T','L','B');
var
b,v:array[0..11,0..11]of boolean;
e,e1,xx,yy,h,num,swap,i,j,s,t:longint;
x,y:array[1..10]of longint;
a:array[0..11,1..2]of longint;
ret,k:string;
begin
readln(ret);
if pos(' ',ret)=0
then begin
val(ret,num);
readln(x[1],y[1]);
b[x[1],y[1]]:=true;
for i:=2 to num do begin
readln(x[i],y[i]);
b[x[i],y[i]]:=true;
end;
{for i:=1 to num-1 do
for j:=i+1 to num do
if (x[i]>x[j])or((x[i]=x[j])and(y[i]>y[j])) then begin
swap:=x[i];x[i]:=x[j];x[j]:=swap;
swap:=y[i];y[i]:=y[j];y[j]:=swap;
end;}
writeln(x[1],' ',y[1]);
for i:=1 to num do
if not v[x[i],y[i]] then begin
v[x[i],y[i]]:=true;
e:=1;e1:=1;h:=1;
a[1,1]:=x[i];a[1,2]:=y[i];
while true do begin
for j:=h to e do begin
if (a[j,1]+1<=10)and(b[a[j,1]+1,a[j,2]])and(not v[a[j,1]+1,a[j,2]])
then begin
inc(e1);a[e1,1]:=a[j,1]+1;a[e1,2]:=a[j,2];
v[a[j,1]+1,a[j,2]]:=true;write('R');
end;
if (a[j,2]+1<=10)and(b[a[j,1],a[j,2]+1])and(not v[a[j,1],a[j,2]+1])
then begin
inc(e1);a[e1,2]:=a[j,2]+1;a[e1,1]:=a[j,1];
v[a[j,1],a[j,2]+1]:=true;write('T');
end;
if (a[j,1]-1>0)and(b[a[j,1]-1,a[j,2]])and(not v[a[j,1]-1,a[j,2]])
then begin
inc(e1);a[e1,1]:=a[j,1]-1;a[e1,2]:=a[j,2];
v[a[j,1]-1,a[j,2]]:=true;write('L');
end;
if (a[j,2]-1>0)and(b[a[j,1],a[j,2]-1])and(not v[a[j,1],a[j,2]-1])
then begin
inc(e1);a[e1,1]:=a[j,1];a[e1,2]:=a[j,2]-1;
v[a[j,1],a[j,2]-1]:=true;write('B');
end;
if j<>num then writeln(',') else writeln('.');
end;
if e1=e then break;
h:=e+1;e:=e1;
end;
end;
end
else begin
k:=copy(ret,1,pos(' ',ret)-1);
val(k,s);
delete(ret,1,pos(' ',ret));
val(ret,t);
x[1]:=s;y[1]:=t;
num:=1;
xx:=x[1];yy:=y[1];
h:=1;e:=1;e1:=1;
while ret<>'.' do begin
for j:=h to e do begin
readln(ret);
for i:=1 to 4 do
if pos(ele[i],ret)<>0 then begin
inc(num);
case i of
1:begin x[num]:=x[j]+1; y[num]:=y[j]; end;
2:begin x[num]:=x[j]; y[num]:=y[j]+1; end;
3:begin x[num]:=x[j]-1; y[num]:=y[j]; end;
4:begin x[num]:=x[j]; y[num]:=y[j]-1; end;
end;
end;
end;
h:=e+1;e:=num
end;
for i:=1 to num-1 do
for j:=i+1 to num do
if (x[i]>x[j])or((x[i]=x[j])and(y[i]>y[j]))
then begin
swap:=x[i];x[i]:=x[j];x[j]:=swap;
swap:=y[i];y[i]:=y[j];y[j]:=swap;
end;
writeln(num);
for i:=1 to num do writeln(x[i],' ',y[i]);
end;
end.
please help me
Edited by author 28.09.2009 20:32