ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1008. Image Encoding

what is wrong?help me!
Posted by better than best 11 Aug 2003 13:16
const
 max    =10;
var
  map    :array[1..max,1..max] of boolean;
  n    :integer;
  nei    :array[1..1000000] of record x,y:integer; end;

  Procedure into;
  var
    i,a,b    :integer;
  begin
    fillchar(map,sizeof(map),false);
    readln(n);
    readln(nei[1].x,nei[1].y);
    writeln(nei[1].x,' ',nei[1].y);
    if n=1 then begin writeln('.'); halt; end;
    for i:=2 to n do
    begin
      readln(a,b);
      map[a,b]:=true;
    end;
  end;

  procedure work;
  var
    i,j,k,p,g    :longint;
    x,y    :integer;
    bool    :boolean;
  begin
    i:=1;
    j:=1;
    repeat
      p:=j;
      bool:=true;
      for g:=i to j do
      begin
       for k:=1 to 4 do
       begin
         x:=nei[g].x;
         y:=nei[g].y;
         case k of
           1:inc(x);
           4:dec(y);
           3:dec(x);
           2:inc(y);
         end;
         if (x>0) and (x<=10) and (y<=10) and (y>0) then
           if map[x,y] then begin
                  case k of
        1:write('R');
        4:write('B');
        3:write('L');
        2:write('T');
                  end;
                  map[x,y]:=false;
                  inc(p);
                  bool:=false;
                  nei[p].x:=x;
                  nei[p].y:=y;
                end;
       end;
       if not((i=j) and bool) then writeln(',')
       else writeln('.');
      end;
      i:=j+1;
      j:=p;
    until bool;
  end;

begin
  into;
  work;
end.