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 I got WA????
Posted by Ural_Mo Luyi 25 Jan 2003 20:01
const f:array[1..4,1..2]of -1..1=((1,0),(0,1),(-1,0),(0,-1));
      ch:array[1..4]of char=('R','T','L','B');

type data=record
          x,y:longint;
          end;
     data1=record
          x,y:integer;
          end;

var a:array[1..100]of data;
    t:array[0..110,0..110]of boolean;
    k:array[1..100]of data1;
    closed,open,i,n:longint;

begin
     fillchar(t,sizeof(t),true);
     readln(n);
     for i:=1 to n do
       readln(a[i].x,a[i].y);
     for i:=2 to n do
       t[a[i].x,a[i].y]:=false;
     writeln(a[1].x,' ',a[1].y);
     closed:=1; open:=0;
     k[1].x:=a[1].x;
     k[1].y:=a[1].y;
     while open<closed do
       begin
            inc(open);
            if open<>1 then writeln(',');
            for i:=1 to 4 do
              if not t[k[open].x+f[i,1],k[open].y+f[i,2]] then
                begin
                     write(ch[i]);
                     t[k[open].x+f[i,1],k[open].y+f[i,2]]:=true;
                     inc(closed);
                     k[closed].x:=k[open].x+f[i,1];
                     k[closed].y:=k[open].y+f[i,2];
                end;
       end;
     writeln('.');
end.
Re: Why I got WA????
Posted by AIT 25 Jan 2003 20:22
> const f:array[1..4,1..2]of -1..1=((1,0),(0,1),(-1,0),(0,-1));
>       ch:array[1..4]of char=('R','T','L','B');
>
> type data=record
>           x,y:longint;
>           end;
>      data1=record
>           x,y:integer;
>           end;
>
> var a:array[1..100]of data;
>     t:array[0..110,0..110]of boolean;
>     k:array[1..100]of data1;
>     closed,open,i,n:longint;
>
> begin
>      fillchar(t,sizeof(t),true);
>      readln(n);
>      for i:=1 to n do
>        readln(a[i].x,a[i].y);
>      for i:=2 to n do
>        t[a[i].x,a[i].y]:=false;
>      writeln(a[1].x,' ',a[1].y);
>      closed:=1; open:=0;
>      k[1].x:=a[1].x;
>      k[1].y:=a[1].y;
>      while open<closed do
>        begin
>             inc(open);
>             if open<>1 then writeln(',');
>             for i:=1 to 4 do
>               if not t[k[open].x+f[i,1],k[open].y+f[i,2]] then
>                 begin
>                      write(ch[i]);
>                      t[k[open].x+f[i,1],k[open].y+f[i,2]]:=true;
>                      inc(closed);
>                      k[closed].x:=k[open].x+f[i,1];
>                      k[closed].y:=k[open].y+f[i,2];
>                 end;
>        end;
>      writeln('.');
> end.

On my mind the input file can contain one of TWO representations.