#K67412. Unique Paths in a Grid
Unique Paths in a Grid
Unique Paths in a Grid
You are given a grid consisting of n rows and m columns. Each cell in the grid is either empty (denoted by .
) or contains a wall (denoted by #
). Your task is to determine the number of unique paths from the top-left corner to the bottom-right corner of the grid. You can only move either one cell to the right or one cell down at any step. You are not allowed to move into or through cells that contain walls.
Since the number of paths can be very large, output the result modulo \(10^9+7\).
Note: The starting cell (top-left corner) and the destination cell (bottom-right corner) are guaranteed to be empty.
inputFormat
The first line contains two integers n and m separated by a space, representing the number of rows and columns of the grid respectively. Following this, there are n lines, each containing a string of length m. Each character in the string is either a dot ('.') indicating an empty cell or a hash ('#') indicating a wall.
outputFormat
Output a single integer: the number of unique paths from the top-left corner to the bottom-right corner modulo (10^9+7).## sample
3 3
...
.#.
...
2