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

I DON'T KNOW WHY I GOT WA???HELLLLLLLP~~~~~PLEASE~~~~~
Posted by windy 29 May 2003 18:58
program windy;
    var
      a:array[0..11,0..11] of 0..1;
      b:array[1..100,1..2] of 0..11;
      n,i,x,y,minx,miny,j:integer;


  procedure init;
    begin
      readln(n);
      for i:= 1 to n do
        begin
          readln(x,y);
          a[x,y]:=1;
          if x<minx then begin
                           minx:=x;
                           miny:=y
                         end
          else if (x=minx) and (y<miny) then miny:=y;
        end;
    end;

   procedure work(i:integer);
     begin
       if i=n then writeln('.')
       else begin
       x:=b[i,1];
       y:=b[i,2];
       if a[x+1,y]=1 then begin
                            write('R');
                            j:=j+1;
                            a[x+1,y]:=0;
                            b[j,1]:=x+1;
                            b[j,2]:=y;
                          end;
       if a[x,y+1]=1 then begin
                            write('T');
                            j:=j+1;
                            a[x,y+1]:=0;
                            b[j,1]:=x;
                            b[j,2]:=y+1;
                          end;
       if a[x-1,y]=1 then begin
                            write('L');
                            j:=j+1;
                            a[x-1,y]:=0;
                            b[j,1]:=x-1;
                            b[j,2]:=y;
                          end;
       if a[x,y-1]=1 then begin
                            write('B');
                            j:=j+1;
                            a[x,y-1]:=0;
                            b[j,1]:=x;
                            b[j,2]:=y-1;
                          end;
       write(',');
       writeln;
       work(i+1)
      end
    end;

    begin
      minx:=20;
      miny:=20;
      fillchar(a,sizeof(a),0);
      fillchar(b,sizeof(b),0);
      init;
      b[1,1]:=minx;
      b[1,2]:=miny;
      writeln(minx,' ',miny);
      j:=1;
      a[minx,miny]:=0;
      work(1);
    end.