#include"bits/stdc++.h"
using namespace std;
int s[10][10];
int n,m,t,x,y,a,b,q,w;
int ans = 0;
int dir[4][2]={
{0,1},{1,0},{0,-1},{-1,0}};//四个方向
void dfs(int xx , int yy)
{
if(xx == a && yy == b){
ans++;
return ;
}
for(int i=0 ; i<4 ; i++){
int tx = xx + dir[i][0];
int ty = yy + dir[i][1];
if(!s[tx][ty] && tx >=1 && ty>=1 && tx<=n && ty<=m){
s[tx][ty]=1;
dfs(tx,ty);
s[tx][ty]=0;
}
}
}
int main()
{
cin >> n >> m >> t;
cin >> x >> y >> a >> b;
s[x][y]=1; // 初始点一定要标记了 , 在这里wa了好久
while(t--)
{
cin >> q >> w;
s[q][w] = 1;
}
dfs(x,y);
cout << ans << endl;
return 0;
}
P1605 迷宫(简单搜索)
猜你喜欢
转载自blog.csdn.net/weixin_53013914/article/details/120620018
今日推荐
周排行