class Solution {
public:
int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {
int row = obstacleGrid.size();
int column = obstacleGrid[0].size();
cout<<row<<endl;
cout<<column<<endl;
int dp[100][100] = { 0 };
int temp;
for (int i = 0; i < row; i++){
if (obstacleGrid[i][0] != 1){
dp[i][0] = 1;
cout << "dp [%d] "<<i<<dp[i][0] << endl;
temp = i+1;
}
else{
break;
}
}
for (int j = temp; j<row; j++){
dp[j][0] = 0;
}
for (int k = 0; k < column; k++){
if (obstacleGrid[0][k] != 1){
dp[0][k] = 1;
temp = k+1;
}
else{
break;
}
}
for (int l = temp; l<column; l++){
dp[0][l] = 0;
}
int res;
for (int m = 1; m < row; m++){
for (int n = 1; n < column; n++){
if (obstacleGrid[m][n] != 1){
dp[m][n] = dp[m - 1][n] + dp[m][n - 1];
}
else{
dp[m][n] = 0;
}
}
}
res = dp[row - 1][column - 1];
return res;
}
};
//这道题就是在后一道的基础上增加了对当前路况的判断,对于边界的处理就是一旦出现障碍,边界之后的方案数变为0。因为出现障碍边界就不能达到终点。
//第二就是对于矩形中间节点的判断,中间一旦出现障碍,就是当前到达当前节点的方案数为0,因为这个点是障碍点不能达到。