A836 | Cave Paintings--Platinum
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Bessie has become an artist and is creating paintings of caves! Her current
work in progress is a grid of height $N$ such that each row of the grid
contains exactly $M$ squares ($1\le N,M\le 1000$). Each square is either
empty, filled with rock, or filled with water. Bessie has already painted the
squares containing rock, including the entire border of the painting. She now
wants to fill some empty squares with water such that if the painting were
real, there would be no net motion of water. Define the height of a square in
the $i$-th row from the top to be $N+1-i$. Bessie wants her painting to
satisfy the following constraint:
Suppose that square $a$ is filled with water. Then if there exists a path from
$a$ to square $b$ using only empty or water squares that are not higher than
$a$ such that every two adjacent squares on the path share a side, then $b$ is
also filled with water.
Find the number of different paintings Bessie can make modulo $10^9+7$. Bessie
may fill any number of empty squares with water, including none or all.
work in progress is a grid of height $N$ such that each row of the grid
contains exactly $M$ squares ($1\le N,M\le 1000$). Each square is either
empty, filled with rock, or filled with water. Bessie has already painted the
squares containing rock, including the entire border of the painting. She now
wants to fill some empty squares with water such that if the painting were
real, there would be no net motion of water. Define the height of a square in
the $i$-th row from the top to be $N+1-i$. Bessie wants her painting to
satisfy the following constraint:
Suppose that square $a$ is filled with water. Then if there exists a path from
$a$ to square $b$ using only empty or water squares that are not higher than
$a$ such that every two adjacent squares on the path share a side, then $b$ is
also filled with water.
Find the number of different paintings Bessie can make modulo $10^9+7$. Bessie
may fill any number of empty squares with water, including none or all.
输入格式
The first line contains two space-separated integers $N$ and $M$.
The next $N$ lines of input each contain $M$ characters. Each character is
either '.' or '#', representing an empty square and a square filled with rock,
respectively. The first and last row and first and last column only contain
'#'.
The next $N$ lines of input each contain $M$ characters. Each character is
either '.' or '#', representing an empty square and a square filled with rock,
respectively. The first and last row and first and last column only contain
'#'.
输出格式
A single integer: the number of paintings satisfying the constraint modulo
$10^9+7$.
$10^9+7$.
输入输出样例
输入 #1
4 9 ######### #...#...# #.#...#.# #########
输出 #1
9
If a square in the second row is filled with water, then all empty squares
must be filled with water. Otherwise, assume that no such squares are filled
with water. Then Bessie can choose to fill any subset of the three
horizontally contiguous regions of empty squares in the third row. Thus, the
number of paintings is equal to $1+2^3=9.$
must be filled with water. Otherwise, assume that no such squares are filled
with water. Then Bessie can choose to fill any subset of the three
horizontally contiguous regions of empty squares in the third row. Thus, the
number of paintings is equal to $1+2^3=9.$
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted