/LINE - Trò chơi Line

<Problem>

http://ntucoder.net/Problem/Details/107
              Uses Crt;
        Var n,sy,sx,dy,dx,i,j,danhdau:longint;
            a:array[-10..1000,-10..1000] of longint;
        Procedure TIM(i,j:longint);
        begin
            if danhdau=1 then exit;
            if a[i,j]=0 then
             begin
                 a[i,j]:=1;
                 if (i=dy) and (j=dx) then
                  begin
                      danhdau:=1;
                      exit;
                  end;
             end;
            if (a[i+1,j]=0) and (i+1<=n) then TIM(i+1,j);
            if (a[i-1,j]=0) and (i-1>=1) then TIM(i-1,j);
            if (a[i,j+1]=0) and (j+1<=n) then TIM(i,j+1);
            if (a[i,j-1]=0) and (j-1>=1) then TIM(i,j-1);
        end;
        Begin
            readln(n,sy,sx,dy,dx);
            for i:=1 to n do
             for j:=1 to n do read(a[i,j]);
            danhdau:=0;
            TIM(sy,sx);
            if danhdau=1 then writeln('YES') else writeln('NO');
            readln;
        ENd.