#C8127. Largest Square of 1's in a Binary Matrix
Largest Square of 1's in a Binary Matrix
Largest Square of 1's in a Binary Matrix
Given a binary matrix with elements either 0 or 1, find the side length of the largest square submatrix consisting entirely of 1's. In other words, locate the largest ( k \times k ) square in the matrix such that every cell in that square is 1.
For example, given the following matrix:
1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0
The largest square submatrix of 1's has a side length of 2.
inputFormat
The input is read from standard input and has the following format:
- The first line contains two integers ( n ) and ( m ) separated by a space, where ( n ) is the number of rows and ( m ) is the number of columns.
- This is followed by ( n ) lines, each containing ( m ) integers (either 0 or 1) separated by spaces representing the matrix.
outputFormat
Output a single integer on standard output: the side length of the largest square submatrix that is completely filled with 1's.## sample
1 4
1 1 1 1
1