#P1681. 最大正方形II
最大正方形II
Description
There is a grid on the picture, consisting of cells. Each cell is colored either black or white. Find a square of maximum area whose interior is black-and-white alternating, that is, any two adjacent unit cells (sharing an edge) must not have the same color.
Input Format
The first line contains two integers and , denoting the number of rows and columns, respectively. Then follow lines, each containing numbers. Each number is or , indicating that the cell is black or white, respectively.
Output Format
Output a single line containing the side length of the largest square that satisfies the condition.
3 3
0 1 0
1 0 0
1 1 1
2
Hint
Sample Explanation: The square from to satisfies the condition, and its side length is .
Constraints:
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号