#C1955. Counting Paths in a Grid
Counting Paths in a Grid
Counting Paths in a Grid
Sarah has been given the task of navigating through a grid from the top-left cell to the bottom-right cell. The grid is represented as an n×m matrix where each cell is either empty (denoted by '.') or blocked (denoted by '#'). Sarah can only move either right or down at each step. Your task is to calculate the total number of distinct paths Sarah can take to reach her destination. The answer should be computed modulo (10^9+7).
Note: The starting cell (top-left) and the destination cell (bottom-right) are guaranteed to be free of obstacles.
inputFormat
The first line contains two integers (n) and (m) representing the number of rows and columns respectively. The next (n) lines each contain a string of length (m), where each character is either '.' (an empty cell) or '#' (an obstacle). It is guaranteed that both the top-left and bottom-right cells are not obstacles.
outputFormat
Output a single integer which is the number of distinct paths from the top-left cell to the bottom-right cell modulo (10^9+7).## sample
3 3
...
.#.
...
2