#K6066. Largest Uniform Square Subgrid
Largest Uniform Square Subgrid
Largest Uniform Square Subgrid
You are given a grid of characters with r rows and c columns. Your task is to find the area of the largest square subgrid in which all the characters are identical.
Input Format: The first line contains two integers r and c which represent the number of rows and columns respectively. The following r lines each contain a string of length c, representing a row in the grid.
Output Format: Output a single integer representing the area of the largest square subgrid where all cells contain the same character. If no such square exists, output 0.
Note: A square subgrid is defined as a contiguous block of cells forming a square.
Example:
For the grid:
3 4 aaaa aabb aabb
The largest uniform square subgrid is of size 2x2 and its area is 4.
The formula for the area of the square is given in LaTeX as: \(Area = side^2\).
inputFormat
The first line contains two space-separated integers, r and c, which represent the number of rows and columns in the grid, respectively.
The next r lines each contain a string of length c consisting of characters.
outputFormat
Output a single integer which is the area of the largest square subgrid that contains the same character.
## sample3 4
aaaa
aabb
aabb
4
</p>