代码:
using namespace std;
bool map_[10][10];//地图
bool temp[10][10];//是否访问
int b1[4]= {0,0,1,-1},b2[4]= {1,-1,0,0};
int sx,sy,fx,fy, n,m,x,y,t,nx,ny,ans=0;
void search(int x,int y){
if(x==fx&&y==fy){
ans++;
return;
}
else{
for(int i=0;i<4;i++){
nx=x+b1[i],ny=y+b2[i];
if(temp[nx][ny]==0 && map_[nx][ny]==0 &&nx>0&&nx<=n &&ny>0&&ny<=m){
temp[nx][ny]=1;
search(nx,ny);
temp[nx][ny]=0;
}
}
}
return;
}
int main(){
cin>>n>>m>>t>>sx>>sy>>fx>>fy;
for(int i=1; i<=t; i++){
cin>>x>>y;
map_[x][y]=1;
}
map_[sx][sy]=1;
search(sx,sy);
cout<<ans;
return 0;
}```