- Time limit: 1.00 s
- Memory limit: 512 MB
You are given an n \times n grid whose each square is either black or white. A subgrid is called beautiful if its height and width is at least two and all of its corners are black. How many beautiful subgrids are there within the given grid?
The first input line has an integer n: the size of the grid.
Then there are n lines describing the grid:
1 means that a square is black and
0 means it is white.
Print the number of beautiful subgrids.
- 1 \le n \le 3000
5 00010 11111 00110 11001 00010