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

Why my program was got WA
Posted by TATUUF 24 Nov 2007 10:55
My program is giving correct answers. But always I got WA1. If you know please help me. There is my code
program ImageEncoding1;
{$APPTYPE CONSOLE}
uses
  SysUtils;
var
   a:array[0..11,0..11]of boolean;
   x,y:array[0..11]of integer;
   f:boolean;
   i,n,x1,y1,k,code,j:integer;
   sn,s:string;
begin
  assign(input,'in.txt');
  assign(output,'out.txt');
  reset(input);
  rewrite(output);
  readln(sn);f:=true;
  //readln(s);
  if(length(sn)<>3)then
  begin
      val(sn,n,code);
      for i:=1 to n do
      begin
         readln(y1,x1);
         if(f)then begin x[1]:=x1;y[1]:=y1;f:=false;end;
         a[y1,x1]:=true;
      end;
      k:=1;i:=1;writeln(y[1],' ',x[1]);a[y[1],x[1]]:=false;
      while i<=k do
      begin
         if(a[y[i]+1,x[i]])then begin k:=k+1;y[k]:=y[i]+1;x[k]:=x[i];  a[y[i]+1,x[i]]:=false;write('R');end;
         if(a[y[i],x[i]+1])then begin k:=k+1;y[k]:=y[i];  x[k]:=x[i]+1;a[y[i],x[i]+1]:=false;write('T');end;
         if(a[y[i]-1,x[i]])then begin k:=k+1;y[k]:=y[i]-1;x[k]:=x[i];  a[y[i]-1,x[i]]:=false;write('L');end;
         if(a[y[i],x[i]-1])then begin k:=k+1;y[k]:=y[i];  x[k]:=x[i]-1;a[y[i],x[i]-1]:=false;write('B');end;
         i:=i+1;
         if(k<i)then write('.')else writeln(',');
      end;
  end
  else
  begin
     val(copy(sn,1,1),y[1],code);
     val(copy(sn,3,1),x[1],code);k:=1;a[y[1],x[1]]:=true;j:=1;
     while(not eof)do
     begin
        readln(s);
        if(s='.')then break;
        n:=length(s);
        for i:=1 to n-1 do
        begin
           if(s[i]='B')then begin k:=k+1;y[k]:=y[j];  x[k]:=x[j]-1;a[y[k],x[k]]:=true;end else
           if(s[i]='T')then begin k:=k+1;y[k]:=y[j];  x[k]:=x[j]+1;a[y[k],x[k]]:=true;end else
           if(s[i]='R')then begin k:=k+1;y[k]:=y[j]+1;x[k]:=x[j];  a[y[k],x[k]]:=true;end
                       else begin k:=k+1;y[k]:=y[j]-1;x[k]:=x[j];  a[y[k],x[k]]:=true;end;
        end;
        j:=j+1;
     end;
     writeln(k);
     for i:=0 to 11 do
       for j:=0 to 11 do
          if(a[i,j])then writeln(i,' ',j);
  end;
end.

Edited by author 29.12.2012 20:54