#K38572. Largest Square Submatrix
Largest Square Submatrix
Largest Square Submatrix
You are given an n × m matrix consisting of non-negative integers. Your task is to find the size (i.e., the side length) of the largest square submatrix in which all the elements are equal.
Formally, let \(A\) be the given matrix. You need to find the maximum integer \(k\) such that there exists some indices \(i, j\) for which all elements \(A_{p,q}\) satisfying \(i \le p \lt i+k\) and \(j \le q \lt j+k\) are equal. The answer is the side length \(k\) of that square.
Note: For a square of side length \(k\) (where \(k \ge 1\)), its area will be \(k^2\), but you are only required to output the side length \(k\).
inputFormat
The input is read from stdin and has the following format:
- The first line contains two integers \(n\) and \(m\) representing the number of rows and columns of the matrix.
- The following \(n\) lines each contain \(m\) non-negative integers separated by spaces, representing the rows of the matrix.
outputFormat
Print to stdout a single integer representing the side length of the largest square submatrix where all the elements are equal.
## sample3 3
1 1 1
1 1 1
1 1 1
3
</p>