#C1161. Largest Square of Zeros in a City Map
Largest Square of Zeros in a City Map
Largest Square of Zeros in a City Map
In a city map, each cell of an n × n matrix represents either a building or an empty space. A cell with a 1 denotes a building, while a cell with a 0 represents an empty space. Your task is to compute the area of the largest square that contains only zeros.
The area of a square is defined as $$Area = side^2$$, where side is the length of the square. If there is no square of zeros, the output should be 0.
For example, given the following matrix:
1 0 1 0 0 1 0 1 1 1 1 0 1 1 1 1 0 0 1 0 0 0 0 0 0
The largest square of zeros has a side length of 2, and its area is 4.
inputFormat
The input is provided via standard input (stdin).
The first line contains a single integer n (n ≥ 0) that represents the size of the matrix. If n > 0, it is followed by n lines, each containing n space-separated integers (each either 0 or 1), representing the rows of the matrix.
outputFormat
Output a single integer to standard output (stdout) representing the area of the largest square that contains only 0s.## sample
5
1 0 1 0 0
1 0 1 1 1
1 0 1 1 1
1 0 0 1 0
0 0 0 0 0
4