#P2601. [ZJOI2009] 对称的正方形

    ID: 1614 远端评测题 1000ms 128MiB 尝试: 1 已通过: 1 难度: 8 上传者: 标签>2009二分各省省选浙江哈希,HASH概率论,统计

[ZJOI2009] 对称的正方形

Description

Orez likes collecting mysterious data and often arranges them into a matrix for study. Recently, Orez obtained some new data and arranged them into an nn-row, mm-column matrix. By observation, Orez found a peculiar number: the count of square submatrices that are symmetric both top-to-bottom and left-to-right. Naturally, Orez wants to know this number, but the matrix is too large to count by hand. Please write a program to compute this number.

Input Format

The first line contains two integers nn and mm. The next nn lines each contain mm positive integers, representing Orez’s matrix.

Output Format

Output a single integer ansans, the number of square submatrices that are symmetric both top-to-bottom and left-to-right.

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 
27

Hint

  • For 30% of the testdata, 1n,m1001 \le n, m \le 100.
  • For 100% of the testdata, 1n,m10001 \le n, m \le 1000, and the values in the matrix do not exceed 10910^9.

Translated by ChatGPT 5