#P2601. Symmetric Square Submatrices

    ID: 15870 Type: Default 1000ms 256MiB

Symmetric Square Submatrices

Symmetric Square Submatrices

Orez loves collecting mysterious data. Recently, he arranged some new data into an $n \times m$ matrix. He observed that the data conceal a peculiar number: the number of square submatrices that are symmetric both vertically and horizontally. A square submatrix of size $L$ is considered symmetric if for every $0 \le i,j < L$, the following conditions hold:

$$A[i][j] = A[L-1-i][j]$$

and

$$A[i][j] = A[i][L-1-j]$$

Your task is to compute the number of such symmetric square submatrices in the given matrix.

inputFormat

The first line contains two integers $n$ and $m$, representing the number of rows and columns of the matrix. Each of the next $n$ lines contains $m$ space-separated integers representing the elements of the matrix.

outputFormat

Output a single integer: the number of square submatrices that are symmetric both vertically and horizontally.

sample

1 1
5
1

</p>