UberOA #48
Maximal Square Area
Estimated MediumJudge-ready
Topics (AI-labelled)Grid DP
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.
Input
The first line contains n m, followed by n 01 strings of length m. 1≤n,m≤300.
Output
Output one integer, the answer.
Example 1
Input:
4 5
10100
10111
11111
10010
Output:
4
Example 2
Input:
2 2
00
00
Output:
0
Example 3
Input:
2 3
111
111
Output:
4
Example notes
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.
Editorial
Loading solution…