시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 123 | 59 | 45 | 42.056% |
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.
The first line will contain a single integer n that indicates the number of data sets that follow. Each data set will start with two integers r and c representing the number of rows and columns of the box, respectively. The next r lines will represent the box, with # representing walls and . representing spaces. The box will be surrounded entirely by walls.
Output the number of discrete (disconnected) sections and the total number of spaces in the box, in the format shown in the example output.
2 4 8 ######## #...#..# #.#.#..# ######## 3 3 ### #.# ###
2 sections, 9 spaces 1 section, 1 space