Topic background
Given an N * M squares maze, T-maze at the barrier, not through the barrier. Given the start point and end point, Q: After a maximum of 1 per box, how many from the start point to the end point coordinate coordinates the program. In the maze to move up and down about four ways, you can only move one square. No obstacles to ensure data starting point.
Title Description
no
Input Format
The first row N, M and T, N row, M being a column, T is the total number of disorders. The second line starting coordinates SX, SY, ending coordinate FX, FY. Then the coordinates of the point T lines, each behavioral disorders.
Output Format
Given the start point and end point, and asked after each square up to 1 times the total number of programs from the starting point to the end point coordinate coordinates.
Sample input and output
2 2 1
1 1 2 2
1 2
1
Description / Tips
[Data] scale
1≤N,M≤5
Code
#include <cstdio>
the using namespace STD;
BOOL G [15] [15], VIS [15] [15]; // G is the total map, VIS whether to access the recording
int n, m, d [5 ] = {-1,0,1,0, -1}; // direction
int NX, NY, EX, EY, the CNT;
// NX, NY starting coordinates; ex, ey end point coordinates, the CNT path Article number
void dfs (int X, Y int) {
IF (X == Y == && EX EY) { // If the end point to
the CNT ++; // add a path to
return; // continue to look back on a return
}
for (int K = 0; K <. 4; K ++) {
int L = X + D [K];
int R & lt = Y + D [K +. 1];
IF (L> =. 1 && R & lt> =. 1 && L <= n-&& R & lt <= m && G [L] [! ! R & lt] && VIS [L] [R & lt]) { // Note starting
VIS [L] [R & lt] = to true; // marked as visited
dfs (l, r);
REGULAR [l] [r] = false; // back
}
}
return; // return a lookup to continue or not if on a proper path, continue to return
}
int main () {
int T, ZX, ZY;
CIN >> >> m >> n-T> > NX NY >> >> >> EX EY;
G [NX] [NY] = to true;
CIN >> >> ZX ZY;
G [ZX] [ZY] = to true; // set disorder
}
DFS (NX, NY); // looking from the start
COUT << the CNT;
return 0;
}