50分。1,3,4,6,9过了。
调试了1个多小时,实在找不到问题,我个蒟蒻。
#include<iostream>
using namespace std;
int n, m, t, s1x, s1y, f1x, f1y, a1n1s = 0, t1x, t1y, a[10][10], b[10][10];
int d1x[] = {-1, 1, 0, 0};
int d1y[] = {0, 0, -1, 1};
void DFS(int x, int y) {
if(x == f1x && y == f1y) {
a1n1s++;
return;
}
for(int i = 0; i < 4; i++) {
int x1x = x + d1x[i];
int y1y = y + d1y[i];
if((x1x >= 1 && x1x <= n && y1y >= 1 && y1y <= m )&& a[x1x][y1y] == 0) {
a[x1x][y1y] = 1;
DFS(x1x, y1y);
a[x1x][y1y] = b[x1x][y1y];
}
}
}
int main() {
cin >> n >> m >> t >> s1x >> s1y >> f1x >> f1y;
for(int i = 1; i <= t; i++) {
cin >> t1x >> t1y;
a[t1x][t1y] = 1;
b[t1x][t1y] = 1;
}
a[s1x][s1y] = 1;
DFS(s1x, s1y);
cout << a1n1s;
return 0;
}