题面翻译
每个人都害怕一些事情。有人怕黑,有人怕高,有人怕维尼琼斯(我们都怕维尼琼斯),有人怕吃东西前唱歌……
有很多恐惧,但对米尔科来说,最大的恐惧是选择种植草莓的土地。米尔科的土地可以描述为一个 N 行 M 列的矩阵。基质中的一些田地适合种植草莓,而有些则不适合——杂草在那里生长。 Mirko 正在寻找长方形的土地,这些土地上长满了适合种植草莓的田地。这类矩形称为合适的矩形。此外,Mirko 对矩阵中所有字段的潜在价值感兴趣。矩阵中每个字段的潜在值定义为包含该字段的合适矩形的数量。
由于 Mirko 难以面对他的恐惧,他要求您只计算所有字段潜在值的总和。
题目描述
Everyone is afraid of something. Someone is afraid of darkness, someone is afraid of heights, someone is afraid of Vinnie Jones (all of us are afraid of Vinnie Jones), someone is afraid of singing before eating something...
There are many fears, but the greatest among all for Mirko is choosing a land for planting strawberries. Mirko's land can be described as a matrix with N rows and M columns. Some of the fields in the matrix are suitable for planting strawberries and some are not – weeds grow there. Mirko is looking for rectangular parts of the land that are completely filled with fields suitable for strawberry planting. Those kind of rectangles are called suitable rectangles. Also, Mirko is interested in the potential value of all fields in the matrix. The potential value of each field in the matrix is defined as the number of suitable rectangles that contain that field.
Since Mirko has troubles facing his fears, he asks you to only calculate the sum of all the fields' potential values.
输入格式
The first line contains two positive integers N and M (1 ≤ N, M ≤ 2 000), dimensions of the land.
The next N lines contains M characters each, representing the landscape. Each character can be either a ‘.’ (dot) which represents a field suitable for planting or a ‘#’ which represents weeds.
第一行包含两个正整数 N 和 M (1 ≤ N, M ≤ 2 000),土地的尺寸。
接下来的 N 行每行包含 M 个字符,代表风景。 每个字符可以是代表适合种植的田地的“.”(点)或代表杂草的“#”。
输出格式
Output the sum of all potential values of the matrix’s fields.
输出矩阵字段的所有潜在值的总和。
样例 #1
样例输入 #1
2 3
.#.
..#
样例输出 #1
8
样例 #2
样例输入 #2
3 3
...
...
...
样例输出 #2
100
样例 #3
样例输入 #3
3 4
..#.
#...
...#
样例输出 #3
40
SCORING
In test cases worth 20% of the total points, it will hold that 1 ≤ N, M ≤ 10.
In test cases worth additional 30% of the total points, it will hold that 1 ≤ N, M ≤ 300.
Clarification of the first sample test:
The following matrix describes the potential values of the land’s fields. The sum of all potential values is 8.
以下矩阵描述了土地领域的潜在价值。 所有潜在值的总和为 8。