#C9576. Largest Island

    ID: 53684 Type: Default 1000ms 256MiB

Largest Island

Largest Island

You are given a grid of size \(n \times m\) consisting of 0's and 1's. Each cell with a value of 1 represents land and a cell with 0 represents water. An island is defined as a group of connected lands (cells with value 1) where the connection is considered only horizontally and vertically.

Your task is to determine the size of the largest island in the grid. The size is the number of cells with value 1 that form the island. If there is no land (1's) in the grid, the answer is 0.

Input and Output: The input will be read from standard input (stdin) and the output should be written to standard output (stdout).

inputFormat

The first line contains two space-separated integers \(n\) and \(m\), representing the number of rows and columns respectively.

Each of the next \(n\) lines contains \(m\) space-separated integers (either 0 or 1) representing the grid.

outputFormat

Output a single integer which is the size of the largest island in the grid.

## sample
6 6
1 1 0 0 0 0
0 1 0 0 1 1
0 0 0 1 1 1
0 0 0 0 0 0
0 0 1 1 1 0
0 0 1 0 0 0
5