测试结果1: 测试结果错误.错误结果为:17
正确结果应为:1
测试结果2: 通过本测试点|有效耗时188ms
测试结果3: 通过本测试点|有效耗时172ms
测试结果4: 通过本测试点|有效耗时47ms
测试结果5: 通过本测试点|有效耗时156ms
测试结果6: 通过本测试点|有效耗时172ms
测试结果7: 通过本测试点|有效耗时172ms
测试结果8: 通过本测试点|有效耗时171ms
测试结果9: 通过本测试点|有效耗时172ms
测试结果10: 通过本测试点|有效耗时172ms
Program bj;
const
step:array[1..4,1..2] of longint=((-1,0),(1,0),(0,-1),(0,1));
var
map:array[0..2000,0..2000] of boolean;
n,m,i,j,x1,y1,x2,y2,ans:longint;
flag:boolean;
procedure bj(x,y:longint);
var
k,t,i:longint;
begin
if (x=x2) and (y=y2) then
begin
flag:=true;
exit;
end;
map[x,y]:=true;
for i:=1 to 4 do
begin
k:=x+step[i,1];
t:=y+step[i,2];
if (k<1) or (k>n) or (t<1) or (t>m) or (map[k,t]) then continue;
inc(ans);
bj(k,t);
if flag then exit;
end;
map[x,y]:=false;
dec(ans);
end;
begin
readln(n,m);
for i:=1 to n do
for j:=1 to m do
begin
read(ans);
if ans=1 then map[i,j]:=true
else map[i,j]:=false;
end;
readln(x1,y1);
readln(x2,y2);
ans:=0;
bj(x1,y1);
if (x1=x2) and (y1=y2) then writeln(0)
else if ans=-1 then writeln('No Answer!')
else writeln(ans);
end.
step:array[1..4,1..2] of longint=((-1,0),(1,0),(0,-1),(0,1));
var
aaa:array[1..2000,1..3] of longint;
a:array[1..2000,1..2000] of longint;
map:array[1..2000,1..2000] of boolean;
ans,x1,x2,y1,y2,n,m,i,j,k,t:longint;
flag:boolean;
procedure wyz(x,y:longint);
var
t,i,s,b1,c1:longint;
begin
if (x=x2) and (y=y2) then
begin
flag:=true;
exit;
end;
map[x,y]:=true;
for i:=1 to 4 do
begin
b1:=x+step[i,1];
c1:=y+step[i,2];
if (b1<1) or (b1>n) or (c1<1) or (c1>m) or (map[b1,c1]) then
continue;
inc(ans);
wyz(b1,c1);
if flag then
exit;
end;
map[x,y]:=false;
dec(ans);
end;
begin
readln(n,m);
for i:=1 to n do
for j:=1 to m do
begin
read(a[i,j]);
if a[i,j]=1 then map[i,j]:=true
else map[i,j]:=false;
end;
readln(x1,y1);
readln(x2,y2);
ans:=0;
wyz(x1,y1);
if ans=-1 then writeln('No Answer!')
else writeln(ans)
end.