大牛改一改

const

a1:array[1..8]of longint=(0,1,1,1,0,-1,-1,-1);

b1:array[1..8]of longint=(1,1,0,-1,-1,-1,0,1);

x1:array[1..4]of longint=(0,1,-1,0);

y1:array[1..4]of longint=(1,0,0,-1);

var

n,m,i,j,l,r,k,a,b,c,d:longint;

x,y,step:array[1..20000]of longint;

vis:array[1..200,1..200]of boolean;

s:array[-1..200,-1..200]of char;

t1,t2,t3,t4:longint;

begin

readln(n,m);

for i:=1 to n do

begin

for j:=1 to m do

read(s);

readln;

end;

fillchar(b,sizeof(b),false);

repeat

readln(t1,t2,t3,t4);

if (t1=0)and(t2=0)and(t3=0)and(t4=0) then halt;

l:=1;r:=1;

step[l]:=0;

x[l]:=t1;

y[l]:=t2;

vis[t1,t2]:=true;

repeat

for j:=1 to 4 do

begin

c:=x[l]+x1[j];

d:=y[l]+y1[j];

for k:=1 to 8 do

begin

a:=c+a1[k];

b:=d+b1[k];

if (a=t3)and(b=t4) then begin writeln(step[l]+1);break;end

else begin

if (a>=0)and(a=0)and(br;

if (l>r) then writeln('Impossible!');

until false;

end.

0 条评论

目前还没有评论...

信息

ID
1263
难度
7
分类
搜索 点击显示
标签
递交数
1420
已通过
242
通过率
17%
被复制
4
上传者