Special Grid

题意翻译

给一个 $n \times m$ 的网格,上下左右以及四个斜方向的相邻点间都连有线。有一些点是黑的,一些是白的,求满足下列条件的三角形个数: - 三个顶点都需要是白点,且不共线。 - 三条边都在图的线上,且仅能穿过白点 输入中 $0$ 代表白色, $1$ 代表黑色。 样例解释中红色和蓝色的为合法的三角形,绿色的为非法的三角形。

题目描述

You are given an $ n×m $ grid, some of its nodes are black, the others are white. Moreover, it's not an ordinary grid — each unit square of the grid has painted diagonals. The figure below is an example of such grid of size $ 3×5 $ . Four nodes of this grid are black, the other $ 11 $ nodes are white. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF435D/2a129804a620070f064ad9f06e8026399abd5ad7.png)Your task is to count the number of such triangles on the given grid that: - the corners match the white nodes, and the area is positive; - all sides go along the grid lines (horizontal, vertical or diagonal); - no side contains black nodes.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ m $ $ (2<=n,m<=400) $ . Each of the following $ n $ lines contain $ m $ characters (zeros and ones) — the description of the grid. If the $ j $ -th character in the $ i $ -th line equals zero, then the node on the $ i $ -th horizontal line and on the $ j $ -th vertical line is painted white. Otherwise, the node is painted black. The horizontal lines are numbered starting from one from top to bottom, the vertical lines are numbered starting from one from left to right.

输出格式


Print a single integer — the number of required triangles.

输入输出样例

输入样例 #1

3 5
10000
10010
00001

输出样例 #1

20

输入样例 #2

2 2
00
00

输出样例 #2

4

输入样例 #3

2 2
11
11

输出样例 #3

0

说明

The figure below shows red and blue triangles. They are the examples of the required triangles in the first sample. One of the invalid triangles is painted green. It is invalid because not all sides go along the grid lines. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF435D/f9604961f586e4f0664ffd8ad99709dfacd15973.png)