P1387 Largest Square

Description

In an $n\times m$ matrix that contains only $0$ and $1$, find a largest square that does not contain any $0$, and output its side length. It is guaranteed that there is at least one $1$ in the matrix.

Input Format

The first line of input contains two integers $n,m(1\leq n,m\leq 100)$. Then follow $n$ lines, each containing $m$ numbers separated by spaces, $0$ or $1$.

Output Format

A single integer, the side length of the largest square.

Explanation/Hint

Translated by ChatGPT 5