测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A11662. Mystical Mosaic

编程题 普及/提高-

题目描述

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 ![](/uploads/luogu/CF924A/970bfdc984412d650a4edcfe5e0a8df4329d1b0b_caa969e2215a.png) or ![](/uploads/luogu/CF924A/74963b959d98ef5a1623c0fa6c3ddc72e6be47dd_bc8be5335c84.png), where ![](/uploads/luogu/CF924A/f53ec93ace7ac116d42268fc65398baf94289b39_e95853152146.png) denotes intersection of sets, and ![](/uploads/acgo/image/c1bad3081a60fd99_18b6de3d0ad4.jpeg) 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.

输出格式

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).

输入输出样例

输入 #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.

![](/uploads/acgo/image/190ff3e1e20b685a_f87ce5241445.jpeg)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.
上一题 去做题 下一题