UberOA #48
Maximal Square Area
估计中等可在线判题
考点(AI 标注)网格动规
In a 01 matrix, find the axis-aligned squares consisting entirely of 1s and return the largest area.
This site has made the standard input and output explicit.
输入格式
The first line contains n m, followed by n 01 strings of length m. 1≤n,m≤300.
输出格式
Output one integer, the answer.
样例 1
输入:
4 5
10100
10111
11111
10010
输出:
4
样例 2
输入:
2 2
00
00
输出:
0
样例 3
输入:
2 3
111
111
输出:
4
样例说明
Example 1: there is an all-1 square of side 2 in the middle, so the largest area is 4. Example 2: everything is 0, so output 0; the original site's second 2×2 input was missing a row, which has been filled in. Example 3: there are only two rows, so the largest side is 2 and the area is 4.