以下是我的代码
#include<bits/stdc++.h>
using namespace std;
int g[50][50],m,n,zai,x,y,bf[50][50],xx,yy,ans,xxx,yyy;
int dx[5]={0,-1,0,1,0},dy[5]={0,0,1,0,-1};
void dfs(int x,int y)
{
if(g[x][y]==3) {ans++;return;}
for(int f=1;f<=4;f++)
{
xx=x+dx[f];
yy=y+dy[f];
if(xx>=1&&xx<=n&&yy>=1&&yy<=m&&g[xx][yy]!=2&&bf[xx][yy]==0)
{
bf[xx][yy]=1;
dfs(xx,yy);
bf[xx][yy]=0;
}
}
}
int main()
{
cin>>m>>n>>zai;
cin>>xxx>>yyy;
g[xxx][yyy]=1;
bf[xxx][yyy]=1;
cin>>x>>y;
g[x][y]=3;
for(int i=1;i<=zai;i++)
{
cin>>x>>y;
g[x][y]=2;
}
dfs(xxx,yyy);
cout<<ans;
return 0;
}
![情况]()
望大佬帮助