Matrix Figures
The day before the Olympics, satellite images of the city were received. Unfortunately, due to poor weather conditions, the images were not of high quality. As a result, it was decided to use their simplified black and white (bit) form.Your task is to analyze this bit form of the image to determine two things: the total number of distinct figures present and the area of the largest figure.A figure is defined as a group of adjacent pixels connected either vertically, horizontally, or diagonally. The area of a figure is the total number of pixels it contains.
Input Data
The first line contains two natural numbers, N and M, representing the height and width of the image, respectively (1 < N, M ≤ 1000). The following N lines each contain M numbers, either 0 or 1. A 1 indicates that the pixel is part of a figure, while a 0 indicates it is not.
Output Data
On the first line, output the total number of figures found in the image. On the second line, output the area of the largest figure.