很奇怪为什么是这样,大部分都能过
#include <bits/stdc++.h>
using namespace std;
int n,m,t;
int ans;
int sx,sy,fx,fy;
bool a[15][15];
int dx,dy;
void dfs(int x, int y)
{
if(x==fx&&y==fy){
ans++;
return;
}
if(a[x+1][y]==false)
{
a[x+1][y]=true;
dfs(x+1,y);
a[x+1][y]=false;
}
if(a[x][y+1]==false)
{
a[x][y+1]=true;
dfs(x,y+1);
a[x][y+1]=false;
}
if(a[x-1][y]==false)
{
a[x-1][y]=true;
dfs(x-1,y);
a[x-1][y]=false;
}
if(a[x][y-1]==false)
{
a[x][y-1]=true;
dfs(x,y-1);
a[x][y-1]=false;
}
return;
}
int main(){
memset(a,true,sizeof(a));
cin>>n>>m>>t;
cin>>sx>>sy>>fx>>fy;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
a[i][j]=false;
}
}
for(int i=1;i<=t;i++){
cin>>dx>>dy;
a[dx][dy]=true;
}
dfs(sx,sy);
cout<<ans<<endl;
return 0;
}