#K53307. Taco Grid Paths
Taco Grid Paths
Taco Grid Paths
You are given an R×C grid where each cell is either open (denoted by .
) or blocked (denoted by #
). Starting from the top-left corner, your task is to determine the number of valid paths that lead to the bottom-right corner. In each step you can move either right or down. The answer should be computed modulo \(10^9+7\).
For example, consider the following test cases:
- For a 3×3 grid:
...\n.#.\n...
, there are 2 valid paths. - For a 1×1 grid with a single open cell (
.
), there is exactly 1 valid path. - For a 3×3 grid:
.#.\n###\n...
, there is no valid path. - For a 4×4 grid where all cells are open, there are 20 valid paths.
inputFormat
The input is read from standard input. The first line contains two integers R and C, representing the number of rows and columns. Each of the next R lines contains a string of length C consisting of characters '.' (open cell) and '#' (blocked cell).
outputFormat
Output a single integer on standard output which is the number of valid paths from the top-left corner to the bottom-right corner of the grid, computed modulo (10^9+7).## sample
3 3
...
.#.
...
2