#K36852. Largest Connected Component

    ID: 25846 Type: Default 1000ms 256MiB

Largest Connected Component

Largest Connected Component

You are given a grid of size \(R \times C\). Each cell of the grid is assigned an integer value representing its altitude. Two cells are considered connected if they share a side (up, down, left, or right) and have the same altitude. Your task is to determine the size of the largest connected component in the grid.

Input: The first line contains two integers \(R\) and \(C\), representing the number of rows and columns, respectively. This is followed by \(R\) lines each containing \(C\) space-separated integers representing the grid.

Output: Print a single integer: the size of the largest connected component.

Example:

Input:
4 5
1 1 0 2 2
3 1 1 2 2
4 4 1 1 0
4 4 4 4 0

Output: 6

</p>

inputFormat

The first line of input contains two space-separated integers \(R\) and \(C\). Each of the next \(R\) lines contains \(C\) space-separated integers, where each integer represents the altitude of a cell in the grid.

outputFormat

Output a single integer representing the size of the largest connected component in the grid.

## sample
4 5
1 1 0 2 2
3 1 1 2 2
4 4 1 1 0
4 4 4 4 0
6

</p>