Holes
InterviewTime limit1sMemory limit1024 MB
Count the connected sections of empty cells in a walled grid, and the total number of empty cells.
Problem
After receiving an impenetrable box, you wonder what's inside! Write a program that finds out how many different disconnected sections the box has, and the total area of the space within the box.
Input
The first line contains a single integer n, the number of data sets that follow. Each data set starts with two integers r and c, the number of rows and columns of the box. The next r lines show the box, with # for walls and . for spaces. The box is surrounded entirely by walls.
Output
Print the number of disconnected sections and the total number of spaces in the box, in the format 2 sections, 9 spaces. Use the singular forms 1 section, 1 space when the count is one.