You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
850 B

#include <bits/stdc++.h>
using namespace std;
const int N = 10;
int g[N][N];
int st[N][N];
int dx[] = {-1, 0, 1, 0}; // 上右下左
int dy[] = {0, 1, 0, -1}; // 上右下左
int n, m, T;
int cnt;
int sx, sy, fx, fy;
void dfs(int x, int y) {
if (x == fx && y == fy) {
cnt++;
return;
}
for (int i = 0; i < 4; i++) {
int tx = x + dx[i], ty = y + dy[i];
if (tx <= 0 || ty <= 0 || tx > n || ty > m) continue;
if (st[tx][ty]) continue;
st[tx][ty] = 1;
dfs(tx, ty);
st[tx][ty] = 0;
}
}
int main() {
cin >> n >> m >> T;
cin >> sx >> sy >> fx >> fy;
while (T--) {
int x, y;
cin >> x >> y;
st[x][y] = 1; // 标障碍点
}
st[sx][sy] = 1;
dfs(sx, sy);
cout << cnt << endl;
return 0;
}