codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

924A.md (2570B)


      1 Source: https://codeforces.com/problemset/problem/924/A
      2 
      3 A. Mystical Mosaic
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 There is a rectangular grid of *n* rows of *m* initially-white cells each.
     22 
     23 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.
     24 
     25 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 ![](https://espresso.codeforces.com/4ac88894f64996c633150129245e8e942fd8c87a.png) or ![](https://espresso.codeforces.com/97e3fd994f862defa2243881d96940d53a455b35.png), where ![](https://espresso.codeforces.com/7be2c0544441f4163b5555e57a9890557fb84ce9.png) denotes intersection of sets, and ![](https://espresso.codeforces.com/b2ae3cdd5aef4a90a3f4ab78b56dd65351be9b3c.png) denotes the empty set.
     26 
     27 You are to determine whether a valid sequence of operations exists that produces a given final grid.
     28 
     29 Input
     30 
     31 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.
     32 
     33 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.
     34 
     35 Output
     36 
     37 If the given grid can be achieved by any valid sequence of operations, output "Yes"; otherwise output "No" (both without quotes).
     38 
     39 You can print each character in any case (upper or lower).
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 5 8  
     47 .#.#..#.  
     48 .....#..  
     49 .#.#..#.  
     50 #.#....#  
     51 .....#..
     52 ```
     53 
     54 Output
     55 
     56 ```
     57 Yes
     58 ```
     59 
     60 Input
     61 
     62 ```
     63 5 5  
     64 ..#..  
     65 ..#..  
     66 #####  
     67 ..#..  
     68 ..#..
     69 ```
     70 
     71 Output
     72 
     73 ```
     74 No
     75 ```
     76 
     77 Input
     78 
     79 ```
     80 5 9  
     81 ........#  
     82 #........  
     83 ..##.#...  
     84 .......#.  
     85 ....#.#.#
     86 ```
     87 
     88 Output
     89 
     90 ```
     91 No
     92 ```
     93 
     94 Note
     95 
     96 For the first example, the desired setup can be produced by 3 operations, as is shown below.
     97 
     98  ![](https://espresso.codeforces.com/315d10362486a9b3b11c3ef50bde291d03a6dfd8.png) 
     99 
    100 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.