CF924A.Mystical Mosaic
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
有一个 n 行 m 列的矩形网格,初始时所有格子均为白色。
Arkady 对其执行了若干次(可能为零次)操作。在第 i 次操作中,选择一个非空的行集合 Ri 和一个非空的列集合 Ci;对每个 r∈Ri 和每个 c∈Ci,将第 r 行与第 c 列的交点(即格子 (r,c))染成黑色。
此外还有一个约束条件:任意一行或一列在整个操作序列中至多被选中一次。换言之,不存在满足 i<j 的下标对 (i,j),使得

或
,
其中
表示集合交集,
表示空集。
你需要判断:是否存在一个满足上述规则的操作序列,能够得到给定的最终网格。
输入格式
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.
第一行包含两个以空格分隔的整数 n 和 m(1 ≤ n, m ≤ 50),分别表示网格的行数和列数。
接下来的 n 行中,每行包含一个长度为 m 的字符串,字符串中的每个字符为 '.'(表示白色单元格)或 '#'(表示黑色单元格),表示所期望的布局。
输出格式
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).
如果给定的网格可以通过任意有效的操作序列得到,则输出“Yes”;否则输出“No”(均不带引号)。
您可以以任意大小写(大写或小写)输出每个字符。
输入输出样例
输入#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.
对于第一个样例,目标布局可以通过 3 次操作实现,如下图所示。

对于第二个样例,目标布局无法实现,因为为了给中间行着色,必须在一次操作中同时选择第三行和所有列;但此后将无法再选择任何列,因此无法给中间列中的其余单元格着色。
输入解题思路,AI测评打分。不知道怎么写?