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

Common Board

Help! What's wrong with my program of 1008?
Posted by Song Chao (ECUST Mutistar) 9 Feb 2002 06:53
const
        MaxN=10;
        DirX:array[1..4] of shortint=(1,0,-1,0);
        DirY:array[1..4] of shortint=(0,1,0,-1);
        DirSign:array[1..4] of char=('R','T','L','B');
        ValidArea:set of 1..MaxN=[1..MaxN];

Type
        TPoint=
                Record
                  X,Y:shortint;
                end;


Var
   NotMarked:array[1..MaxN,1..MaxN] of boolean;
   head,rear,N,i,j,k,p:integer;
   Tx,Ty,Ox,Oy:shortint;
   List:array[1..MaxN*MaxN] of TPoint;


begin
  for i:=1 to MaxN do
    for j:=1 to MaxN do
      NotMarked[i,j]:=false;
  readln(N);
  Readln(Ox,Oy);
  head:=1;rear:=2; List[1].X:=Ox; List[1].Y:=Oy;
  for i:=2 to N do
  begin
    Readln(Tx,Ty);
    NotMarked[Tx,Ty]:=true;
  end;
  writeln(Ox,' ',Oy);
  while (head<rear) do
  begin
    for i:=1 to 4 do
    begin
      Tx:=List[Head].X+DirX[i];
      Ty:=List[Head].Y+DirY[i];
      if (Tx in ValidArea) and (Ty in ValidArea) and NotMarked[Tx,Ty]
        then
          begin
            NotMarked[Tx,Ty]:=false;
            List[rear].X:=Tx;
            List[rear].Y:=Ty;
            inc(rear);
            write(DirSign[i]);
          end;
    end;
    inc(head);
    if head<rear then writeln(',') else writeln('.');
  end;

end.