mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 17:51:58 +00:00
P1605 迷宫
R42180362
This commit is contained in:
parent
c365bbcc70
commit
3d98210ff3
34
problem/P1605/P1605.cpp
Normal file
34
problem/P1605/P1605.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#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;
|
||||
for(int i = 0 ; i < t ; i++) {
|
||||
int x, y;
|
||||
cin >> x >> y;
|
||||
vis[x][y] = -1;
|
||||
}
|
||||
dfs(sx, sy);
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user