https://www.luogu.org/problem/show?pid=1958
深搜搜索路径条数即可,注意方向
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define ms(i,j) memset(i, j, sizeof i);
const int dx[2] = {1,0};
const int dy[2] = {0,1};
int map[20][20];
bool vi[20][20];
int a,b;
int n;
int ans = 0;
int dfs(int x, int y)
{
if ((x==a)&&(y==b)) {ans++; return 0;}
for (int i=0;i<2;i++)
{
int tx = x+dx[i], ty = y+dy[i];
if (tx>0&&ty>0&&tx<=a&&ty<=b&&!map[tx][ty]&&!vi[tx][ty])
{
vi[tx][ty] = true;
dfs(tx,ty);
vi[tx][ty] = false;
}
}
}
int main()
{
scanf("%d%d%d", &a, &b, &n);
ms(map,0);
for (int i=1;i<=n;i++)
{
int xi, yi;
scanf("%d%d" ,&xi, &yi);
map[xi][yi] = 1;
}
ms(vi,false);
dfs(1,1);
printf("%d" ,ans);
system("pause");
return 0;
}