CF435D.Special Grid
普及+/提高
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.

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.
给你一个 n×m 的网格,其中部分格点为黑色,其余为白色。此外,这不是一个普通网格——每个单位正方形的两条对角线均已被涂色。
下图是一个大小为 3×5 的此类网格示例。该网格中有 4 个黑点,其余 11 个点为白点。

你的任务是计算该网格中满足以下条件的三角形的个数:
- 三个顶点均为白点,且三角形面积为正;
- 所有边均沿网格线(水平、竖直或对角线)延伸;
- 任意一条边上都不包含黑点。
输入格式
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.
第一行包含两个整数 n 和 m(2≤n,m≤400)。接下来的 n 行,每行包含 m 个字符(仅由 0 和 1 组成),描述网格。若第 i 行中的第 j 个字符为 0,则位于第 i 条水平线与第 j 条垂直线交点处的节点被涂成白色;否则该节点被涂成黑色。
水平线从上到下编号,起始编号为 1;垂直线从左到右编号,起始编号为 1。
输出格式
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.

下图展示了红色和蓝色的三角形。它们是第一个样例中所要求的三角形的示例。其中一个无效的三角形被涂成绿色。它之所以无效,是因为并非所有边都沿网格线延伸。

输入解题思路,AI测评打分。不知道怎么写?