codeforces-scrape

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

844B.md (1314B)


      1 Source: https://codeforces.com/problemset/problem/844/B
      2 
      3 B. Rectangles
      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 You are given *n* × *m* table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:
     22 
     23 1. All cells in a set have the same color.
     24 2. Every two cells in a set share row or column.
     25 
     26 Input
     27 
     28 The first line of input contains integers *n* and *m* (1 ≤ *n*, *m* ≤ 50) — the number of rows and the number of columns correspondingly.
     29 
     30 The next *n* lines of input contain descriptions of rows. There are *m* integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.
     31 
     32 Output
     33 
     34 Output single integer  — the number of non-empty sets from the problem description.
     35 
     36 Examples
     37 
     38 Input
     39 
     40 ```
     41 1 1  
     42 0
     43 ```
     44 
     45 Output
     46 
     47 ```
     48 1
     49 ```
     50 
     51 Input
     52 
     53 ```
     54 2 3  
     55 1 0 1  
     56 0 1 0
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 8
     63 ```
     64 
     65 Note
     66 
     67 In the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.