Areas
72% Success1812 Attempts10 Points2s Time Limit256MB Memory1024 KB Max Code
You are given a 2D grid. A '#' represents an obstacle and a '.' represents free space. You need to find the areas of the disconnected components. The cells (i+1, j), (i, j+1), (i-1, j), (i, j-1) are the adjacent to the cell (i, j).
There are multiple test cases in this problem.
Examples
Input
3 3 3 ##. ..# #.# 3 5 #.#.# .#.#. #.#.# 4 4 ..## ..## ##.. ##..
Output
2 1 3 7 1 1 1 1 1 1 1 2 4 4
Explanation
In the first test case, there are 2 components with areas 1 and 3 respectively.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Loading Editor...
Results