Counting Rooms
You are given a map of a building, and your task is to count the number of its rooms. The size of the map is \(N \times M\) squares, and each square is either floor or wall. You can walk left, right, up, and down through the floor squares.
Input Specification
The first line has two integers \(N\) and \(M\): the height and width of the map. Then there are \(N\) lines of \(M\) characters describing the map. Each character is either . (floor) or # (wall).
Output Specification
Print one integer: the number of rooms.
Constraints
\(1 \le n,m \le 1000\)
Sample Input
5 8
########
#..#...#
####.#.#
#..#...#
########
Sample Output
3
Comments
is there necessarily a border of '#'s around each building or can there be a '.' on the edge of the building like
'###'
'## .'
'###'
is this a valid building
nvm im cracked