题意
走迷宫,要绕开障碍,走过的就不能再走,求有多少种不同的方法可以到达终点
分析
我们可以用深搜来做,输入时把障碍的坐标记录下来
const
dx:array[1..4]of longint=(0,0,1,-1);
dy:array[1..4]of longint=(1,-1,0,0);
var
n,m,t,sx,sy,fx,fy,tj,i,z1,z2:longint;
a:array[-100..100,-100..100]of longint;
procedure search(x,y:longint);
var
i:longint;
begin
if (a[x,y]=1)or(x<1)or(x>n)or(y<1)or(y>m) then exit;
if (x=fx)and(y=fy) then
begin
inc(tj);
exit;
end;
a[x,y]:=1;
for i:=1 to 4 do
begin
x:=x+dx[i];
y:=y+dy[i];
search(x,y);
x:=x-dx[i];
y:=y-dy[i];
end;
a[x,y]:=0;
end;
begin
readln(n,m,t);
readln(sx,sy,fx,fy);
fillchar(a,sizeof(a),0);
for i:=1 to t do
begin
readln(z1,z2);
a[z1,z2]:=1;
end;
tj:=0;
search(sx,sy);
write(tj);
end.