#K77932. Koma's Grid Journey
Koma's Grid Journey
Koma's Grid Journey
You are given a grid with R rows and C columns. Each cell in the grid is either an open cell represented by '.' or a blocked cell represented by '#' . Koma starts at the top-left cell (0, 0) and wants to reach the bottom-right cell (R-1, C-1). She can only move either down or right at each step.
Your task is to calculate the number of distinct paths Koma can take to reach the goal while avoiding blocked cells. Since the answer can be large, output the result modulo \(10^9+7\).
Note: If the starting cell or the destination cell is blocked, then the number of paths is 0.
inputFormat
The input is read from stdin and has the following format:
- The first line contains two integers R and C separated by a space.
- The next R lines each contain a string of C characters, representing the grid. The character
.
denotes an open cell and#
denotes a blocked cell.
outputFormat
Output a single integer to stdout — the number of distinct paths from the top-left to the bottom-right cell, modulo \(10^9+7\).
## sample3 3
..#
#..
...
2
</p>