#C9970. Largest Uniform Square Submatrix
Largest Uniform Square Submatrix
Largest Uniform Square Submatrix
You are given a matrix composed of characters. Your task is to determine the side length of the largest square submatrix in which every element is the same. A submatrix here is defined as a contiguous block of cells.
Let \(M\) be the number of rows and \(N\) the number of columns in the matrix. The input begins with a line containing \(M\) and \(N\), followed by \(M\) lines each containing \(N\) space-separated characters.
Example:
Input: 5 6 a a a b b b a a a b b b a a a c c c b b b c c c b b b c c c</p>Output: 3
In the example above, the largest square submatrix with all characters identical is of size \(3 \times 3\), hence the output is 3.
inputFormat
The first line of input contains two integers \(M\) and \(N\) which denote the number of rows and columns of the matrix respectively. It is followed by \(M\) lines, each containing \(N\) characters separated by a single space.
outputFormat
Output a single integer representing the side length of the largest square submatrix in which all elements are the same.
## sample5 6
a a a b b b
a a a b b b
a a a c c c
b b b c c c
b b b c c c
3