CF924A.Mystical Mosaic

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a rectangular grid of nn rows of mm initially-white cells each.

Arkady performed a certain number (possibly zero) of operations on it. In the ii -th operation, a non-empty subset of rows RiR_{i} and a non-empty subset of columns CiC_{i} are chosen. For each row rr in RiR_{i} and each column cc in CiC_{i} , the intersection of row rr and column cc 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) ( i<ji<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 nn and mm (1<=n,m<=50(1<=n,m<=50 ) — the number of rows and columns of the grid, respectively.

Each of the following nn lines contains a string of mm 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 33 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.

首页