一.题目描述
Farmer John is going into the ice cream business! He has built a machine that produces blobs of ice cream but unfortunately in somewhat irregular shapes, and he is hoping to optimize the machine to make the shapes produced as output more reasonable.
The configuration of ice cream output by the machine can be described using an N×NN×N grid (1≤N≤10001≤N≤1000) as follows:
##.... ....#. .#..#. .##### ...### ....##Each '.' character represents empty space and each '#' character represents a 1×11×1 square cell of ice cream.
Unfortunately, the machine isn't working very well at the moment and might produce multiple disconnected blobs of ice cream (the figure above has two). A blob of ice cream is connected if you can reach any ice cream cell from every other ice cream cell in the blob by repeatedly stepping to adjacent ice cream cells in the north, south, east, and west directions.