#K33732. Grid Path Counting with Obstacles

    ID: 25153 Type: Default 1000ms 256MiB

Grid Path Counting with Obstacles

Grid Path Counting with Obstacles

Given a grid of size R × C, where each cell is either open ('.') or blocked ('#'), determine the number of distinct paths from the top-left cell (0,0) to the bottom-right cell (R-1, C-1). Only moves to the right or down are allowed. The answer must be computed modulo \(10^9+7\).

If the starting cell or the destination cell is blocked, the answer should be 0. Use dynamic programming to solve the problem efficiently.

inputFormat

The first line contains two integers R and C, representing the number of rows and columns in the grid.

Each of the next R lines contains a string of C characters. Each character is either '.' (indicating an open cell) or '#' (indicating a blocked cell).

outputFormat

Output a single integer representing the number of distinct paths from the top-left cell to the bottom-right cell modulo \(10^9+7\).

## sample
3 3
...
.#.
...
2

</p>