题库练习 Mystical Mosaic
← 上一题 下一题 →

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 ![](/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
C++ 编辑器
输入
输出