CF628E.Zbazi in Zeydabad
提高+/省选-
通过率:0%
时间限制:5.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A tourist wants to visit country Zeydabad for Zbazi (a local game in Zeydabad).
The country Zeydabad is a rectangular table consisting of n rows and m columns. Each cell on the country is either 'z' or '.'.
The tourist knows this country is named Zeydabad because there are lots of ''Z-pattern"s in the country. A ''Z-pattern" is a square which anti-diagonal is completely filled with 'z' and its upper and lower rows are also completely filled with 'z'. All other cells of a square can be arbitrary.

Note that a ''Z-pattern" can consist of only one cell (see the examples).
So he wants to count the number of ''Z-pattern"s in the country (a necessary skill for Zbazi).
Now your task is to help tourist with counting number of ''Z-pattern"s.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
一名游客想去泽伊达巴德国(Zeydabad)游玩当地游戏“泽巴齐”(Zbazi)。
泽伊达巴德国是一个由 n 行 m 列构成的矩形表格。表格中每个单元格的内容要么是字符 'z',要么是 '.'。
这名游客知道该国名为“泽伊达巴德”,是因为其境内存在大量“Z型图案”(Z-pattern)。一个“Z型图案”是一个正方形区域,满足:其反对角线(即从右上到左下的对角线)上的所有单元格均为 'z',且该正方形的最上一行与最下一行也必须全部由 'z' 填满。该正方形内其余所有单元格的内容可为任意字符(即 'z' 或 '.')。

注意:“Z型图案”可以仅由单个单元格构成(参见样例)。
因此,他希望统计该国境内“Z型图案”的总数(这是玩“泽巴齐”所必需的一项技能)。
现在你的任务就是帮助该游客统计“Z型图案”的数量。
由于输入/输出规模可能非常大,建议使用快速输入/输出方法:例如,在 C++ 中优先使用 gets/scanf/printf 而非 getline/cin/cout;在 Java 中优先使用 BufferedReader/PrintWriter 而非 Scanner/System.out。
输入格式
The first line contains two integers n, m (1 ≤ n, m ≤ 3000) — the number of rows and columns respectively.
Each of the next n lines contains m characters 'z' or '.' — the description of Zeydabad.
第一行包含两个整数 n 和 m(1≤n,m≤3000),分别表示行数和列数。
接下来的 n 行,每行包含 m 个字符,每个字符为 'z' 或 '.' —— 表示泽伊达巴德的地图描述。
输出格式
Print the only integer a — the number of ''Z-pattern"s in Zeydabad.
输出唯一的整数 a —— 泽伊达巴德市中“Z型图案”的数量。
输入输出样例
输入#1
4 4 zzzz zzz. .z.. zzzz
输出#1
16
输入#2
1 4 z.z.
输出#2
2
输入#3
2 2 zz zz
输出#3
5
输入解题思路,AI测评打分。不知道怎么写?