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 1377. Lara Croft

Why I have WA???I know my program is true!!!
Posted by Chalyh Alexander 6 Apr 2006 10:34
program LARACROWT;
Var  a:array[1..100,1..100] of longint;
     n,m,j,i,k,max: Longint;
     x1,y1,x2,y2  : Longint;
{-------------------------------------------------------}
procedure init;
begin
readln(n,m);
readln(x1,y1);
readln(x2,y2);
end;
{-------------------------------------------------------}
procedure print;
begin
writeln(abs(a[x1,y1]-a[x2,y2]));halt;
halt;
end;
{-------------------------------------------------------}
procedure solve;
var q1,q2,q3,q4:longint;
    w1,w2,w3,w4:longint;
begin
w1:=1;q1:=1;w2:=1;q2:=n;w3:=1;q3:=n;w4:=1;q4:=1;
     repeat
           for i:=w1 to n-w1+1 do
            begin
              inc(max);a[q1,i]:=max;
              if max=n*n then print;
            end;inc(w1);inc(q1);

           for i:=w2+1 to n-w2+1 do
            begin
              inc(max);a[i,q2]:=max;
              if max=n*n then print;
            end;inc(w2);dec(q2);

           for i:=n-w3 downto w3 do
            begin
              inc(max);a[q3,i]:=max;
              if max=n*n then print;
            end;inc(w3);dec(q3);

           for i:=n-w4 downto w4+1 do
            begin
              inc(max);a[i,q4]:=max;
              if max=n*n then print;
            end;inc(w4);inc(q4);




     until max=n*n;
end;
{-------------------------------------------------------}
BEGIN
init;
solve;
print;
END.