Emacs
InterviewTime limit1sMemory limit512 MB
Count the non-overlapping, non-touching rectangles of '*' characters in an N by M grid.
- Level
Medium4 of 10
- Topics
- Implementation, Array, BFS, DFS
- Solved
- No attempts yet
Problem
While playing in his favourite text editor, Daniel decided to draw a picture that is N characters high and M characters wide. The picture consists solely of the characters '.' and '*', and the '*' characters form some non-overlapping rectangles. The rectangles do not touch each other, not even on their sides or corners.
Help Daniel count the number of rectangles drawn in the picture.
Input
The first line contains two integers N and M (1 ≤ N, M ≤ 100). Each of the next N lines contains M characters '.' or '*', representing the picture Daniel drew.
Output
Print the number of rectangles in the picture on a single line.