~/algor $ cat problems/matritsa-eng-katta-birlar-kvadrati
Largest square of ones
Medium
1000 ms
128 MB
66%
A matrix of size $n \times m$ consisting only of $0$ and $1$ is given. Find the side length of the largest square submatrix made only of $1$.
Input
The first line contains two positive integers $n$ and $m$. Each of the next $n$ lines contains $m$ numbers ($0$ or $1$).
Output
One integer — the side length of the largest square ($0$ if there are no ones).
Note
$1 \le n, m \le 200$
$a_{i,j} \in \{0, 1\}$
Examples
Input #1
4 5 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0
Output #1
3
Input #2
2 2 0 0 0 0
Output #2
0