QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 70

#13386. 钻石

Statistics

Lovro 有一个 $n$ 行 $m$ 列的表格,其中每个单元格要么是 .,要么是 #。将一个正方形旋转 $45^\circ$ 即可在表格中形成一个菱形。若要使表格中的某一部分被视为菱形,其边缘必须仅由字符 # 组成,而其内部必须完全填充 . 且不能为空。菱形外部允许出现任何字符。菱形有不同的大小,第一个样例展示了三种最小的菱形示例。

Fabijan 要求 Lovro 告诉他表格中有多少个菱形,否则 Lovro 就得给他一块饼干。请编写一个程序,帮助 Lovro 计算他表格中菱形的数量。

输入格式

第一行包含正整数 $n$ 和 $m$ ($1 \le n, m \le 2000$),表示行数和列数。 接下来的 $n$ 行,每行包含 $m$ 个字符(.#),用于描述表格。

输出格式

在唯一的一行中输出表格中菱形的数量。

子任务

子任务 分值 数据范围
1 20 $1 \le n, m \le 100$
2 50 无附加限制

样例

输入格式 1

7 25
.#...#....#....#.....#...
#.#..#...#.#...#....#.#..
.#...#..#...#..#...#...#.
.....#...#.#...#..#.....#
.....#....#....#...#...#.
.....#.........#....#.#..
.....#.........#.....#...

输出格式 1

3

输入格式 2

11 17
.....#........#..
....#.#........#.
...#...#....#...#
..#.....#....#.#.
.#....#..#....#..
#....#.#..#......
.#....#..#.......
..#.....#........
...#...#.........
....#.#..........
.....#...........

输出格式 2

1

说明

第二个样例的说明: 表中只有一个菱形(即最小尺寸的那个)。虽然看起来还有另一个包含它的菱形,但它不被视为菱形,因为其内部没有完全填充 .。表格右侧的形状也不是菱形,因为它缺少边缘上的 # 字符。

输入格式 3

5 11
##.#.#.#.##
#.#.#.#.#.#
.#.#.#.#.#.
#.#.#.#.#.#
##.#.#.#.##

输出格式 3

14

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.