A11662 | Mystical Mosaic
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There is a rectangular grid of $n$ rows of $m$ initially-white cells each.
Arkady performed a certain number (possibly zero) of operations on it. In the $i$ -th operation, a non-empty subset of rows $R_{i}$ and a non-empty subset of columns $C_{i}$ are chosen. For each row $r$ in $R_{i}$ and each column $c$ in $C_{i}$ , the intersection of row $r$ and column $c$ is coloured black.
There's another constraint: a row or a column can only be chosen at most once among all operations. In other words, it means that no pair of $(i,j)$ ( $i<j$ ) exists such that  or , where  denotes intersection of sets, and  denotes the empty set.
You are to determine whether a valid sequence of operations exists that produces a given final grid.
Arkady performed a certain number (possibly zero) of operations on it. In the $i$ -th operation, a non-empty subset of rows $R_{i}$ and a non-empty subset of columns $C_{i}$ are chosen. For each row $r$ in $R_{i}$ and each column $c$ in $C_{i}$ , the intersection of row $r$ and column $c$ is coloured black.
There's another constraint: a row or a column can only be chosen at most once among all operations. In other words, it means that no pair of $(i,j)$ ( $i<j$ ) exists such that  or , where  denotes intersection of sets, and  denotes the empty set.
You are to determine whether a valid sequence of operations exists that produces a given final grid.
输入格式
The first line contains two space-separated integers $n$ and $m$ $(1<=n,m<=50$ ) — the number of rows and columns of the grid, respectively.
Each of the following $n$ lines contains a string of $m$ characters, each being either '.' (denoting a white cell) or '\#' (denoting a black cell), representing the desired setup.
Each of the following $n$ lines contains a string of $m$ characters, each being either '.' (denoting a white cell) or '\#' (denoting a black cell), representing the desired setup.
输出格式
If the given grid can be achieved by any valid sequence of operations, output "Yes"; otherwise output "No" (both without quotes).
You can print each character in any case (upper or lower).
You can print each character in any case (upper or lower).
输入输出样例
输入 #1
5 8 .#.#..#. .....#.. .#.#..#. #.#....# .....#..
输出 #1
Yes
输入 #2
5 5 ..#.. ..#.. ##### ..#.. ..#..
输出 #2
No
输入 #3
5 9 ........# #........ ..##.#... .......#. ....#.#.#
输出 #3
No
For the first example, the desired setup can be produced by $3$ operations, as is shown below.
For the second example, the desired setup cannot be produced, since in order to colour the center row, the third row and all columns must be selected in one operation, but after that no column can be selected again, hence it won't be possible to colour the other cells in the center column.
For the second example, the desired setup cannot be produced, since in order to colour the center row, the third row and all columns must be selected in one operation, but after that no column can be selected again, hence it won't be possible to colour the other cells in the center column.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted