252. Largest Square of Ones
MediumDynamic ProgrammingGrid
Print the area of the largest square containing only 1s in the binary grid.
Input format
Line 1: r c Next r lines: c values (0/1)
Output format
The area.
Example 1
Input
4 5 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0
Output
4
Example 2
Input
2 2 0 1 1 0
Output
1
Constraints
1 ≤ r, c ≤ 500
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…