Muddy Fields
Rain has pummeled the cows' field, a rectangular grid of R rows and
C columns (1 <= R <= 50, 1 <= C <= 50). While good for the grass,
the rain makes some patches of bare earth quite muddy. The
cows, being meticulous grazers, don't want to get their hooves dirty
while they eat.
To prevent those muddy hooves, Farmer Z will place a number of
wooden boards over the muddy parts of the cows' field. Each of the
boards is 1 unit wide, and can be any length long. Each board must
be aligned parallel to one of the sides of the field.
Farmer Z wishes to minimize the number of boards needed to cover
the muddy spots, some of which might require more than one board
to cover. The boards may not cover any grass and deprive the cows
of grazing area but they can overlap each other.
Compute the minimum number of boards FZ requires to cover all the mud in
the field.
PROBLEM NAME: muddy.X
INPUT FORMAT:
* Line 1: Two space-separated integers: R and C
* Lines 2..R+1: Each line contains a string of C characters, with '*'
representing a muddy patch, and '.' representing a grassy
patch. No spaces are present.
SAMPLE INPUT:
4 4
*.*.
.***
***.
..*.
OUTPUT FORMAT:
* Line 1: A single integer representing the number of boards FZ needs.
SAMPLE OUTPUT:
4
OUTPUT DETAILS:
Boards 1, 2, 3 and 4 are placed as follows:
1.2.
.333
444.
..2.
Board 2 overlaps boards 3 and 4.