1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #include <bits/stdc++.h> using namespace std; const int LEN = 6; int N, M, bg_x, bg_y, ed_x, ed_y, ans; int arr[LEN][LEN], vis[LEN][LEN], obs[LEN][LEN], walk[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
void dfs(int x, int y) { if (x < 1 || x > N || y < 1 || y > M || vis[x][y]) return; if (x == ed_x && y == ed_y) { ++ans; return; } vis[x][y] = 1; for (int i = 0; i < 4; ++i) dfs(x + walk[i][0], y + walk[i][1]); vis[x][y] = 0; }
int main() { int t, x, y; cin >> N >> M >> t >> bg_x >> bg_y >> ed_x >> ed_y; while (t--) { cin >> x >> y; vis[x][y] = 1; } dfs(bg_x, bg_y); cout << ans; return 0; }
|