题目描述
Problem Description
Tsubasa's department is currently流行 (trendy) with drawing pictures. Tsubasa is known as a "画伯" (master artist) among his peers because he draws very unique pictures. Given the method Tsubasa uses to draw and a sample picture, let's predict what kind of picture he will draw.
Drawing method:
The picture is a rectangle of \(M \\times N\\) squares, where the square at the \(i\\)-th row from the top and the \(j\\)-th column from the left is denoted as \((i,j)\\). The colors of the squares are represented by a 2D array \(a\\), where \(a\_{ij}\\) is 0 for white and 1 for black. Tsubasa first selects one square \((x,y)\\) that satisfies \(1 \\leq x \\leq M - 1\\) and \(1 \\leq y \\leq N - 1\\). Then, he divides all squares \((i,j)\\) into four rectangles represented by:
- \(1 \\leq i \\leq x\\), \(1 \\leq j \\leq y\\)
- \(1 \\leq i \\leq x\\), \(y \\lt j \\leq N\\)
- \(x \\lt i \\leq M\\), \(1 \\leq j \\leq y\\)
- \(x \\lt i \\leq M\\), \(y \\lt j \\leq N\\)
He rotates each of these four rectangles 180 degrees and places them back into their original positions to complete the picture.
Example:
Suppose a \(3 \\times 3\\) rectangle sample is as follows:
```
101
010
100
If Tsubasa selects the square \\((1,1)\\), it is divided into the following four rectangles:
```
1|01
-+--
0|10
1|00
After rotating each rectangle 180 degrees, it becomes:
```
1|10
-+--
1|00
0|01
Placing them back into their original positions, the completed picture is:
```
110
100
001
Tsubasa also mentioned:
- The number of black squares in each row and column does not change before and after the operation.
How many squares can Tsubasa potentially select?
Input Format
The input is given from the standard input in the following format:
```
\(M\) \(N\)
\(a_{11}\)\(\dots\)\(a_{1N}\)
\(\vdots\)
\(a_{M1}\)\(\dots\)\(a_{MN}\)
## Output Format
Output the number of potentially selectable squares.
## Sample Input and Output
### Sample Input #1
3 3
101
010
100
### Sample Output #1
1
### Sample Input #2
2 3
101
010
### Sample Output #2
2
### Sample Input #3
16 26
00000000000000000000000000
00000000000000000000000000
00000000111111111111110000
00000011111111111111110000
00001111110000000000000000
00001111110000000000000000
00001111110000000000000000
00001111110000000000000000
00001111110000000000000000
00001111110000000000000000
00001111110000000000000000
00001111110000000000000000
00000011111111111111110000
00000000111111111111110000
00000000000000000000000000
00000000000000000000000000
### Sample Output #3
0
```
Notes/Hints
Constraints
- \(2 \\leq M, N \\leq 10^5\\)
- \(4 \\leq M \\times N \\leq 5 \\times 10^5\\)
- \(a\_{ij}\\) is either
0or1 - All input values are integers.
Sample Explanation 1
The only square Tsubasa can select is \((1,1)\\).
Sample Explanation 2
Tsubasa can select two squares: \((1,1)\\) and \((1,2)\\).
Sample Explanation 3
Tsubasa cannot select any squares.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分