#K79487. Largest Uniform Rectangle in a Grid
Largest Uniform Rectangle in a Grid
Largest Uniform Rectangle in a Grid
You are given an n x m grid in which each cell contains an integer between 0 and 9. Your task is to find the area of the largest rectangle within the grid where all the numbers are the same.
Formally, you must determine the maximum area of a contiguous subrectangle (with sides parallel to the grid) such that every cell within the subrectangle has the same value. The area of a rectangle is defined as its width multiplied by its height.
Note: The grid dimensions and the numbers in the grid are given as input. Your solution should read from standard input and output the answer to standard output.
inputFormat
The first line contains two integers n
and m
— the number of rows and columns in the grid, respectively.
Each of the following n
lines contains m
space‐separated integers representing the grid.
outputFormat
Output a single integer representing the area of the largest rectangle in the grid where all the cells have the same value.
## sample2 3
1 1 1
1 1 1
6