As the title implies, your task in this problem is related to maze, specifically a 2D maze of Nmathbf{N}N rows and Mmathbf{M}M columns , where rows are numbered from 1{1}1 to Nmathbf{N}N from top to bottom, and columns are numbered from 1 to Mmathbf{M}M from left to right. The cell at the i-th row and the j-th column is denoted by (i,j){}(i,j). The maze has only one entry which is at (1,1){}(1,1) and only one exit which is at (N,M)(N,M). To simplify things, you are only allowed to move right or down at any step. There might be cells with obstacle which cannot be visited, and there might be cells with treasure which must be visited. In this problem, you are requested to count the number of valid paths from the starting location to the ending location. There are Smathbf{S}S cells with treasure. The valid path should visit all cells with treasure. The following cells with obstacle, the valid path cannot visit any cell with obstacle. all cells (x,y){}(x,y) meet x>yx gt yx>y, all cells (x,y){}(x,y) meet M+x
As the title implies, your task in this problem is related to maze, specifically a 2D maze of Nmathbf{N}N rows and Mmathbf{M}M columns (N≤Mmathbf{N} leq mathbf{M}N≤M), where rows are numbered from 1{1}1 to Nmathbf{N}N from top to bottom, and columns are numbered from 1 to Mmathbf{M}M from left to right. The cell at the i-th row and the j-th column is denoted by (i,j){(i, j)}(i,j). The maze has only one entry which is at (1,1){(1, 1)}(1,1) and only one exit which is at (N,M)(mathbf{N}, mathbf{M})(N,M). To simplify things, you are only allowed to move right or down at any step. There might be cells with obstacle which cannot be visited, and there might be cells with treasure which must be visited. In this problem, you are requested to count the number of valid paths from the starting location to the ending location. There are Smathbf{S}S cells with treasure. The valid path should visit all cells with treasure. The following cells with obstacle, the valid path cannot visit any cell with obstacle. all cells (x,y){(x, y)}(x,y) meet x>yx gt yx>y, all cells (x,y){(x, y)}(x,y) meet M+x
标签: HBC202149Maze题解