#C10435. Largest Island Size

    ID: 39640 Type: Default 1000ms 256MiB

Largest Island Size

Largest Island Size

Given a grid of size \( n \times m \) where each cell contains either \(0\) (representing water) or \(1\) (representing land), determine the size of the largest island. An island is defined as a group of adjacent land cells (connected horizontally or vertically).

Input: The first line contains two integers \(n\) and \(m\). Each of the next \(n\) lines contains \(m\) space-separated integers (either 0 or 1) representing the grid.

Output: Output a single integer representing the size of the largest island in the grid.

Example:

Input:
4 5
1 1 0 0 0
1 1 0 1 1
0 0 0 0 1
0 0 0 1 1

Output: 5

</p>

inputFormat

The first line contains two integers \(n\) and \(m\) (number of rows and columns respectively). The following \(n\) lines each contain \(m\) integers, where each integer is either \(0\) (water) or \(1\) (land).

outputFormat

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

## sample
4 5
1 1 0 0 0
1 1 0 1 1
0 0 0 0 1
0 0 0 1 1
5