type jl=record
m,n:integer;
z:longint;
end;
const d:array[1..4,1..2]of integer=((0,1),(0,-1),(1,0),(-1,0));
var b:array[0..1001,0..1001]of boolean;
a:array[1..1000000]of jl;
i,j,x,y,k,l,n,h,p:integer; c:char;
begin
readln(n);
for i:=0 to n+1 do
for j:=0 to n+1 do b[i,j]:=false;
for i:=1 to n do begin
for j:=1 to n-1 do begin
read(c);
if c='0' then b[i,j]:=true;
end;
readln(c);
if c='0' then b[i,10]:=true;
end;
h:=1; p:=1;
readln(a[p].m,a[p].n); a[p].z:=0; b[a[p].m,a[p].n]:=false;
readln(x,y);
repeat
for i:=1 to 4 do begin
k:=d[i,1]+a[h].m; l:=d[i,2]+a[h].n;
if (k=x)and (l=y)then begin writeln(a[h].z+1); halt; end;
if b[k,l]=true then begin
b[k,l]:=false;
inc(p); a[p].m:=k;a[p].n:=l; a[p].z:=a[h].z+1;
end;
end;
inc(h);
until h>p;
end.
测试结果1: 通过本测试点|有效耗时156ms
测试结果2: 通过本测试点|有效耗时172ms
测试结果3: 测试结果错误.错误结果为:81
正确结果应为:1065
测试结果4: 测试结果错误.错误结果为:81
正确结果应为:476
测试结果5: 测试结果错误.错误结果为:81
正确结果应为:439
测试结果6: 测试结果错误.错误结果为:81
正确结果应为:558
测试结果7: 通过本测试点|有效耗时500ms
测试结果8: 测试结果错误.错误结果为:155
正确结果应为:581
测试结果9: 测试结果错误.错误结果为:155
正确结果应为:745
测试结果10: 测试结果错误.错误结果为:155
正确结果应为:1013