#d1406. “Z”型矩阵
“Z”型矩阵
"Z" Matrix
Problem Description
For a matrix containing only . and z, it is called a Z matrix when all of the following hold:
- The matrix has equal numbers of rows and columns.
- The first row and the last row are entirely
z. - The diagonal from the top-right corner to the bottom-left corner is entirely
z.
Now given an matrix, count how many of its submatrices are Z matrices.
Input Format
The first line contains two integers , the number of rows and columns of the matrix respectively ().
The next lines each contain characters, describing the matrix.
Output Format
Output one integer: the number of Z matrices.
Sample Input
4 4
zzzz
z.z.
.zz.
zzzz
Sample Output
14