QOJ.ac

QOJ

時間限制: 3 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#13294. Symmetric Square

统计

Orez likes to collect mysterious data and often arranges them into a matrix for research. Recently, Orez obtained some data and arranged it into an $n \times m$ matrix. Through observation, Orez discovered that this data contains a peculiar number: the count of square submatrices that are both vertically and horizontally symmetric.

Orez naturally wants to know what this number is, but the matrix is too large to count manually. Please write a program to calculate this number.

Input

The first line contains two integers $n$ and $m$. The next $n$ lines each contain $m$ positive integers, representing the matrix Orez obtained.

Output

The output should contain a single integer answer, representing the number of square submatrices in the matrix that are both vertically and horizontally symmetric.

Examples

Input 1

5 5
4 2 4 4 4
3 1 4 4 3
3 5 3 3 3
3 1 5 3 3
4 2 1 2 4

Output 1

27

Constraints

For 30% of the data: $n, m \le 100$

For 100% of the data: $n, m \le 1000$, the values in the matrix are $\le 10^9$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.