#P7715. 「EZEC-10」Shape
「EZEC-10」Shape
Description
Person A has an grid. Some cells are white, and the remaining cells are black.
Person A chooses four integers satisfying the following conditions:
- and .
- is even.
If all cells on the following three segments are white: , , , then the shape formed by these three segments is called an H-shape.
Person A wants to know how many different H-shapes exist in the grid.
Two H-shapes are the same if and only if their are all the same.
Input Format
The first line contains two integers .
The next lines each contain integers describing the grid, where means a white cell and means a black cell.
Output Format
Output one integer, representing the number of different H-shapes.
3 4
1 0 0 0
1 1 0 0
1 0 0 0
1
5 3
0 1 0
0 1 0
0 0 0
0 1 0
0 1 0
2
Hint
[Sample 1 Explanation]
The H-shape with is valid.
[Sample 2 Explanation]
The H-shapes with and are valid.
[Constraints]
This problem uses bundled testdata.
- Subtask 1 (1 point): .
- Subtask 2 (9 points): .
- Subtask 3 (10 points): , time limit is .
- Subtask 4 (30 points): .
- Subtask 5 (50 points): no special constraints.
For of the data, .
Translated by ChatGPT 5
京公网安备 11011102002149号