CF1393D.Rarity and New Dress
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Carousel Boutique is busy again! Rarity has decided to visit the pony ball and she surely needs a new dress, because going out in the same dress several times is a sign of bad manners. First of all, she needs a dress pattern, which she is going to cut out from the rectangular piece of the multicolored fabric.
The piece of the multicolored fabric consists of n×m separate square scraps. Since Rarity likes dresses in style, a dress pattern must only include scraps sharing the same color. A dress pattern must be the square, and since Rarity is fond of rhombuses, the sides of a pattern must form a 45∘ angle with sides of a piece of fabric (that way it will be resembling the traditional picture of a rhombus).
Examples of proper dress patterns:
Examples of improper dress patterns:
The first one consists of multi-colored scraps, the second one goes beyond the bounds of the piece of fabric, the third one is not a square with sides forming a 45∘ angle with sides of the piece of fabric.
Rarity wonders how many ways to cut out a dress pattern that satisfies all the conditions that do exist. Please help her and satisfy her curiosity so she can continue working on her new masterpiece!
旋转精品店又忙碌起来了!瑞瑞决定去参加小马舞会,她当然需要一条新裙子,因为多次穿同一条裙子出门是失礼的表现。首先,她需要一个裙装纸样,而这个纸样将从一块矩形的多色布料上裁剪出来。
这块多色布料由 n×m 个独立的正方形布片组成。由于瑞瑞崇尚时尚,裙装纸样所包含的布片必须颜色完全相同。此外,裙装纸样本身必须是一个正方形;又因瑞瑞钟爱菱形,该正方形的各边必须与布料的边成 45∘ 夹角(这样看起来才像传统意义上的菱形)。
符合要求的裙装纸样示例:

不符合要求的裙装纸样示例:

第一个示例中包含了多种颜色的布片,第二个超出了布料边界,第三个不是与布料边成 45∘ 角的正方形。
瑞瑞很好奇:究竟有多少种满足上述所有条件的裙装纸样裁剪方案?请帮她解答这一疑问,以便她能继续创作她的全新杰作!
输入格式
The first line contains two integers n and m (1≤n,m≤2000). Each of the next n lines contains m characters: lowercase English letters, the j-th of which corresponds to scrap in the current line and in the j-th column. Scraps having the same letter share the same color, scraps having different letters have different colors.
第一行包含两个整数 n 和 m(1≤n,m≤2000)。接下来的 n 行,每行包含 m 个字符:小写英文字母;其中第 j 个字符表示当前行、第 j 列位置上的碎屑。具有相同字母的碎屑颜色相同,具有不同字母的碎屑颜色不同。
输出格式
Print a single integer: the number of ways to cut out a dress pattern to satisfy all of Rarity's conditions.
输出一个整数:满足瑞瑞所有条件的连衣裙图案裁剪方案数。
输入输出样例
输入#1
3 3 aaa aaa aaa
输出#1
10
输入#2
3 4 abab baba abab
输出#2
12
输入#3
5 5 zbacg baaac aaaaa eaaad weadd
输出#3
31
说明/提示
In the first example, all the dress patterns of size 1 and one of size 2 are satisfactory.
In the second example, only the dress patterns of size 1 are satisfactory.
在第一个例子中,所有尺寸为 1 的连衣裙图案以及一个尺寸为 2 的连衣裙图案均满足要求。
在第二个例子中,仅有尺寸为 1 的连衣裙图案满足要求。
输入解题思路,AI测评打分。不知道怎么写?