#K76717. Count Safe Grid Paths
Count Safe Grid Paths
Count Safe Grid Paths
You are given a grid with n rows and m columns. Each cell is either safe (denoted by .
) or dangerous (denoted by *
). Your task is to determine the number of ways to travel from the top-left corner (cell (1, 1)) to the bottom-right corner (cell (n, m)) using only right and down moves, while avoiding dangerous cells. If either the starting or ending cell is dangerous, the result is 0.
Since the answer may be very large, output the result modulo \(998244353\).
inputFormat
The first line contains two integers n and m (the number of rows and columns). The following n lines each contain a string of length m consisting of the characters .
(safe cell) and *
(dangerous cell).
outputFormat
Output a single integer representing the number of safe paths from the top-left corner to the bottom-right corner modulo \(998244353\).
## sample3 3
...
.*.
...
2