#C2620. Largest Uniform Altitude Rectangle
Largest Uniform Altitude Rectangle
Largest Uniform Altitude Rectangle
You are given a grid that represents altitudes, with \(N\) rows and \(M\) columns. Your task is to determine the area of the largest rectangle in the grid such that every cell in the rectangle has the same altitude. The sides of the rectangle must be parallel to the grid axes.
The area is computed by the formula:
\( \text{area} = \text{width} \times \text{height} \)
where the width is the number of contiguous cells in a row and the height is the number of contiguous rows.
Input and output are handled via standard input (stdin) and standard output (stdout), respectively.
inputFormat
The input begins with an integer \(T\) representing the number of test cases. For each test case, the first line contains two space‐separated integers \(N\) and \(M\) denoting the number of rows and columns. This is followed by \(N\) lines, each containing \(M\) integers which represent the grid's altitudes.
outputFormat
For each test case, output a single integer on a new line representing the area of the largest rectangle with uniform altitude.
## sample6
3 4
1 2 2 3
1 1 1 3
3 3 3 3
2 3
1 2 2
2 2 2
3 3
1 1 1
1 1 2
1 1 2
4 4
5 5 5 5
5 5 5 5
5 5 5 5
5 5 5 5
1 5
1 2 2 2 1
5 1
1
2
2
2
1
4
4
6
16
3
3
</p>