A8116 | Domino Carpet
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
...Mike the TV greets you again!
Tired of the monotonous furniture? Sick of gray routine? Dreaming about dizzying changes in your humble abode? We have something to offer you!
This domino carpet for only $99.99 will change your life! You can lay it on the floor, hang it on the wall or even on the ceiling! Among other things ...
Having watched the commercial, virus Hexadecimal also wanted to get a Domino Carpet and wanted badly to be photographed in front of it. But of course, a virus will never consent to buying a licensed Carpet! So she ordered a truck of dominoes and decided to make such a Carpet herself.
The original Domino Carpet is a field of squares$ n×m $in size. Each square is half of a domino, and can be rotated either vertically or horizontally, independently from its neighbors. Vertically rotated domino halves look like this:
And horizontally rotated halves look like this:
Notice, that some halves looks the same in both rotations, but other halves differ.
Dominoes bought by Hexadecimal are represented by uncuttable chips$ 1×2 $in size, which can be laid either vertically or horizontally. If the chip is laid vertically, then both of it's halves should be laid vertically orientated; if the chip is laid horizontally, then both of it's halves should be laid horizontally.
The samples of valid and invalid dominoes laid vertically and horizontally are:
Virus Hexadecimal assembles her own Domino Carpet so that the following conditions are satisfied:
- each carpet square is covered by a domino chip, i.e. there are no empty squares;
- all domino chips lie entirely within the carpet and don't overlap with each other;
- if there is a horizontal domino chip with its left half in column$ j $then there are no horizontal domino chips with their left halves in columns$ j-1 $or$ j+1 $.
Before starting to assemble her own Domino Carpet, the virus wants to know the number of ways to achieve the intended purpose modulo$ 10^{9}+7 $.
You can assume that the virus has an infinitely large number of dominoes of each type.
Tired of the monotonous furniture? Sick of gray routine? Dreaming about dizzying changes in your humble abode? We have something to offer you!
This domino carpet for only $99.99 will change your life! You can lay it on the floor, hang it on the wall or even on the ceiling! Among other things ...
Having watched the commercial, virus Hexadecimal also wanted to get a Domino Carpet and wanted badly to be photographed in front of it. But of course, a virus will never consent to buying a licensed Carpet! So she ordered a truck of dominoes and decided to make such a Carpet herself.
The original Domino Carpet is a field of squares$ n×m $in size. Each square is half of a domino, and can be rotated either vertically or horizontally, independently from its neighbors. Vertically rotated domino halves look like this:
And horizontally rotated halves look like this:
Notice, that some halves looks the same in both rotations, but other halves differ.
Dominoes bought by Hexadecimal are represented by uncuttable chips$ 1×2 $in size, which can be laid either vertically or horizontally. If the chip is laid vertically, then both of it's halves should be laid vertically orientated; if the chip is laid horizontally, then both of it's halves should be laid horizontally.
The samples of valid and invalid dominoes laid vertically and horizontally are:
Virus Hexadecimal assembles her own Domino Carpet so that the following conditions are satisfied:
- each carpet square is covered by a domino chip, i.e. there are no empty squares;
- all domino chips lie entirely within the carpet and don't overlap with each other;
- if there is a horizontal domino chip with its left half in column$ j $then there are no horizontal domino chips with their left halves in columns$ j-1 $or$ j+1 $.
Before starting to assemble her own Domino Carpet, the virus wants to know the number of ways to achieve the intended purpose modulo$ 10^{9}+7 $.
You can assume that the virus has an infinitely large number of dominoes of each type.
输入格式
The first line contains two integers $n$ and $m$ , separated by a space — the size of the Domino Carpet ( $1<=n,m<=250$ ). Next $4n+1$ lines contain $4m+1$ symbols.
Each square of the Domino Carpet, which is a domino half, is described by a $3×3$ square. Symbol 'O' in this square indicates the presence of a point, symbol '.' — its absence.
Each $3×3$ square is delineated from adjacent squares by symbols '#' as shown in the examples.
It is guaranteed that every box describes the correct half of a domino.
In all pretests the Domino Carpets have the size of $2×2$ and $4×4$ .
Each square of the Domino Carpet, which is a domino half, is described by a $3×3$ square. Symbol 'O' in this square indicates the presence of a point, symbol '.' — its absence.
Each $3×3$ square is delineated from adjacent squares by symbols '#' as shown in the examples.
It is guaranteed that every box describes the correct half of a domino.
In all pretests the Domino Carpets have the size of $2×2$ and $4×4$ .
输出格式
Print a single number, the number of ways to assemble the Domino Carpet modulo $10^{9}+7$ , using only standard dominoes of size $1×2$ .
输入输出样例
输入 #1
3 4 ################# #O..#...#O.O#...# #.O.#.O.#.O.#...# #..O#...#O.O#...# ################# #O.O#OOO#O.O#...# #.O.#...#...#.O.# #O.O#OOO#O.O#...# ################# #O.O#...#O.O#...# #...#...#...#.O.# #O.O#...#O.O#...# #################
输出 #1
3
输入 #2
2 2 ######### #O.O#O.O# #.O.#...# #O.O#O.O# ######### #...#O.O# #...#...# #...#O.O# #########
输出 #2
2
输入 #3
2 2 ######### #..O#O..# #...#...# #O..#..O# ######### #O..#..O# #...#...# #..O#O..# #########
输出 #3
0
A note to the first example: all correct ways to make Domino Carpet are represented below:
And this way is incorrect:

And this way is incorrect:

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted