#C8781. Largest Square of 1s in a Binary Matrix
Largest Square of 1s in a Binary Matrix
Largest Square of 1s in a Binary Matrix
You are given a binary matrix of size \(m \times n\) filled with 0s and 1s. Your task is to determine the side length of the largest square sub-matrix that contains only 1s. The sides of the square must be parallel to the matrix rows and columns.
Example:
Input: 4 5 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0</p>Output: 2
In the above example, the largest square of 1s has a side length of 2.
inputFormat
The first line of input contains two integers \(m\) and \(n\), representing the number of rows and columns of the matrix, respectively. The next \(m\) lines each contain \(n\) space-separated integers (each either 0 or 1) that represent a row of the matrix.
outputFormat
Output a single integer representing the side length of the largest square sub-matrix containing only 1s.
## sample4 5
1 0 1 0 0
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0
2
</p>