#C570. Finding the Largest Island

    ID: 49378 Type: Default 1000ms 256MiB

Finding the Largest Island

Finding the Largest Island

You are given a grid of size \(R \times C\) consisting solely of 0s and 1s. Each cell with value 1 represents land and 0 represents water. An island is defined as a group of adjacent lands connected horizontally or vertically (not diagonally). Your task is to compute the size of the largest island present in the grid.

Input Format: The first line contains two integers \(R\) and \(C\) indicating the number of rows and columns in the grid. This is followed by \(R\) lines, each containing \(C\) space-separated integers (either 0 or 1).

Output Format: Output a single integer: the size of the largest island. If there is no island, output 0.

Note: Use standard input (stdin) to read input and standard output (stdout) to write output.

inputFormat

The input is given as follows:

R C
row_1
row_2
...
row_R

Where each row_i consists of \(C\) space-separated integers (0 or 1).

outputFormat

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

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