SP21671 JUMPPY - Jumppy and the Grid
Description
Jumppy likes to jump! One day Jumppy went to a park. Jumppy can jump all over the park.The park can be thought of as a square grid with square cells of side length 1. The contents of the grid is either 0(zero) or X. There are certain things which Jumppy likes. They are:
->Jumppy likes rectangles.
->Jumppy likes X.
Therefore Jumppy will jump only in the rectangles consisting of X. A rectangle is defined as follows:
1)The whole rectangular region should contain only X.
2)The rectangle should be surrounded with 0 or the boundary of the grid.
3)The diagonally adjacent cell(see the definition) of the corner of the rectangle may be X or 0.(Refer to the first example).
Diagonally adjacent cell: Suppose the given cell has coordinates (p,q) then its diagonally adjacent cells would have coordinates (p+1,q+1) , (p+1,q-1) , (p-1,q+1) , (p-1,q-1).
Now Jumppy is curious how many rectangles are there in the park. Help Jumppy find the number of rectangle.INPUT:
An integer n denoting the side of the grid.
Then n lines follow each containing a string of n characters describing the square grid. All the characters will be either 0 or X.
OUTPUT:
Output the number of rectangles in the given grid.
CONSTRAINTS:
0 < n