#K13691. Counting Paths in a Grid with Traps
Counting Paths in a Grid with Traps
Counting Paths in a Grid with Traps
You are given an MxN grid where each cell is either free (represented by '.') or a trap (represented by '#'). Starting from the top-left cell, your task is to count the number of distinct paths to reach the bottom-right cell. You can only move either to the right or down at each step. Since the number of paths may be large, return the answer modulo \(10^9+7\).
Note: If the starting cell is a trap, then no path exists.
Input Format: The first line contains two integers M and N, representing the number of rows and columns in the grid. The next M lines each contain a string of length N representing the grid.
Output Format: Output a single integer, the number of distinct paths from the start to the destination modulo \(10^9+7\>.
inputFormat
The input is read from standard input and has the following format:
M N row1 row2 ... rowM
Here, M and N are integers representing the number of rows and columns, and each row is a string of length N composed of '.' (free cell) and '#' (trap).
outputFormat
The output is a single integer printed to standard output representing the number of distinct paths from the top-left to the bottom-right corner modulo \(10^9+7\).
## sample3 3
...
.#.
...
2