0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 23:36:32 +00:00
OI-codes/Luogu/P1605/P1605.cpp

35 lines
636 B
C++
Raw Normal View History

2020-11-19 11:39:25 +00:00
#include <bits/stdc++.h>
using namespace std;
int n, m, t, sx, sy, fx, fy, ans;
int vis[10][10];
void dfs(int x, int y) {
if (x < 1 || y < 1 || x > n || y > n || vis[x][y] == -1 || vis[x][y] == 1) {
return;
}
if (x == fx && y == fy) {
ans++;
return;
}
vis[x][y] = 1;
dfs(x - 1, y);
dfs(x, y - 1);
dfs(x, y + 1);
dfs(x + 1, y);
vis[x][y] = 0;
}
int main() {
cin >> n >> m >> t >> sx >> sy >> fx >> fy;
2021-11-19 09:01:13 +00:00
for (int i = 0; i < t; i++) {
2020-11-19 11:39:25 +00:00
int x, y;
cin >> x >> y;
vis[x][y] = -1;
}
dfs(sx, sy);
cout << ans << endl;
return 0;
}