A12926 | Rock Is Push
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are at the top left cell $(1, 1)$ of an $n \times m$ labyrinth. Your goal is to get to the bottom right cell $(n, m)$ . You can only move right or down, one cell per step. Moving right from a cell $(x, y)$ takes you to the cell $(x, y + 1)$ , while moving down takes you to the cell $(x + 1, y)$ .
Some cells of the labyrinth contain rocks. When you move to a cell with rock, the rock is pushed to the next cell in the direction you're moving. If the next cell contains a rock, it gets pushed further, and so on.
The labyrinth is surrounded by impenetrable walls, thus any move that would put you or any rock outside of the labyrinth is illegal.
Count the number of different legal paths you can take from the start to the goal modulo $10^9 + 7$ . Two paths are considered different if there is at least one cell that is visited in one path, but not visited in the other.
Some cells of the labyrinth contain rocks. When you move to a cell with rock, the rock is pushed to the next cell in the direction you're moving. If the next cell contains a rock, it gets pushed further, and so on.
The labyrinth is surrounded by impenetrable walls, thus any move that would put you or any rock outside of the labyrinth is illegal.
Count the number of different legal paths you can take from the start to the goal modulo $10^9 + 7$ . Two paths are considered different if there is at least one cell that is visited in one path, but not visited in the other.
输入格式
The first line contains two integers $n, m$ — dimensions of the labyrinth ( $1 \leq n, m \leq 2000$ ).
Next $n$ lines describe the labyrinth. Each of these lines contains $m$ characters. The $j$ -th character of the $i$ -th of these lines is equal to "R" if the cell $(i, j)$ contains a rock, or "." if the cell $(i, j)$ is empty.
It is guaranteed that the starting cell $(1, 1)$ is empty.
Next $n$ lines describe the labyrinth. Each of these lines contains $m$ characters. The $j$ -th character of the $i$ -th of these lines is equal to "R" if the cell $(i, j)$ contains a rock, or "." if the cell $(i, j)$ is empty.
It is guaranteed that the starting cell $(1, 1)$ is empty.
输出格式
Print a single integer — the number of different legal paths from $(1, 1)$ to $(n, m)$ modulo $10^9 + 7$ .
输入输出样例
输入 #1
1 1 .
输出 #1
1
输入 #2
2 3 ... ..R
输出 #2
0
输入 #3
4 4 ...R .RR. .RR. R...
输出 #3
4
In the first sample case we can't (and don't have to) move, hence the only path consists of a single cell $(1, 1)$ .
In the second sample case the goal is blocked and is unreachable.
Illustrations for the third sample case can be found here: <https://assets.codeforces.com/rounds/1225/index.html>
In the second sample case the goal is blocked and is unreachable.
Illustrations for the third sample case can be found here: <https://assets.codeforces.com/rounds/1225/index.html>
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted