#C2671. Unique Paths in a Grid with Obstacles
Unique Paths in a Grid with Obstacles
Unique Paths in a Grid with Obstacles
You are given an ( m \times n ) grid where each cell is either free (denoted by 0) or an obstacle (denoted by 1). Your task is to calculate the number of unique paths from the top-left cell to the bottom-right cell. You are only allowed to move either right or down at any step. A cell with a value of 1 is considered a wall and cannot be included in your path. Use dynamic programming to solve the problem efficiently.
inputFormat
Input is read from standard input (stdin) in the following format:\n- The first line contains two integers ( m ) and ( n ), where ( m ) is the number of rows and ( n ) is the number of columns.\n- The next ( m ) lines each contain ( n ) space-separated integers (either 0 or 1) representing the grid.
outputFormat
Output a single integer to standard output (stdout) representing the number of unique paths from the top-left corner to the bottom-right corner of the grid.## sample
3 3
0 0 0
0 1 0
0 0 0
2