Problem A
Clock Construction

Engineers at Spectre Imaging have decided to start investing in smart clock market. They are creating a prototype clock that will be able to show some images.

The clock’s rectangular display consists of black-and-white pixels. A pixel can have two states: ON or OFF. Since it is a complicated process to construct such a display, Spectre Imaging came up with the idea to divide the pixels into groups, where all pixels in a group would either be ON or OFF.

Given the screen resolution of the clock and the set of pictures that must be shown on the display, what is the minimal number of groups that are needed do be able to display all of the pictures?


The first line contains integers $N$, $H$ and $W$ ($1 \leq N, H, W \leq 100$) – the number of images that must be shown, the height of the display in pixel, and the width of the display in pixels respectively.

After that follows $N$ images. Each image consists of $H$ lines with $W$ characters each. All of these lines consists only of a ’*’ or a ’.’ which correspond to a pixel being ON or OFF respectively in the picture.


Output a single integer: the minimal number of pixel groups into which the display can be divided into in order to be able to display all the pictures.

Explanation of sample 1

One possible solution is to divide the display into the following for groups:

Explanation for sample input 1 (each of the $4$ pixel groups):
1.. .2. ... ..4
1.. ... .3. ..4

Then, the first image can be displayed by turning on the first pixel group, the second image by turning on the first and the second group, and the third image by turning on the third group.

Note that pixel group $4$ was never turned on, but every pixel still needs to belong to a group.

Sample Input 1 Sample Output 1
3 2 3

Please log in to submit a solution to this problem

Log in