4336. Mine sweeper

单点时限: 1.0 sec

内存限制: 256 MB

Now, little w is playing the game Mine-sweeper. The game is working on a $n \times m$ grid field and each cell contains 0 or 1 mine.

For each cell, little w only know the total number of mines in itself and its 8 adjacent cells. He wants to know the total number of mines in this field, please help him.

输入格式

The first line contains two positive integers $n$ and $m$. $(1 \leq n, m \leq 200)$

In the following $n$ lines, each line contains $m$ integers. And each number represents the information little w knows of a cell, the total number of mines in itself and its 8 adjacent cells.

输出格式

One line with one integer represents the total number of mines.

样例

Input
3 4
2 3 2 1
2 3 2 1
1 2 2 1
Output
3
Input
4 5
1 1 3 3 3
1 2 5 5 4
0 1 4 5 4
0 1 3 4 3
Output
8

提示

For example, suppose the number of mine in a field likes

011
010
000

Then little w will know

233
233
111

63 人解决,71 人已尝试。

71 份提交通过,共有 134 份提交。

2.9 EMB 奖励。

创建: 3 年,2 月前.

修改: 3 年,2 月前.

最后提交: 1 年,4 月前.

来源: N/A

题目标签