305720: CF1080E. Sonya and Matrix Beauty
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Sonya and Matrix Beauty
题意翻译
# 题目描述 一句话题意:给定一个 $n \times m$ 的字符矩阵,请求出有多少个子矩阵在重排子矩阵每一行的字符后,使得子矩阵的每行每列都是回文串。 Sonya 最近过了生日,她收到一个 $n \times m$ 的字符矩阵。 我们称一个子矩阵是美丽的,当且仅当在重新排列这个子矩阵每一行的字符后,使得这个子矩阵的每一行每一列都是回文串。 Sonya 想要知道这个矩阵中有几个子矩阵是美丽的。 # 输入格式 第一行两个整数 $n,m$,意义如上文所述。 接下来 $n$ 行一行 $m$ 个字符,表示这个子矩阵每一行的字符。 # 输出格式 一行一个整数,表示美丽的子矩阵数目 # 数据范围 对于 $1 \leq m,n \leq 250$题目描述
Sonya had a birthday recently. She was presented with the matrix of size $ n\times m $ and consist of lowercase Latin letters. We assume that the rows are numbered by integers from $ 1 $ to $ n $ from bottom to top, and the columns are numbered from $ 1 $ to $ m $ from left to right. Let's call a submatrix $ (i_1, j_1, i_2, j_2) $ $ (1\leq i_1\leq i_2\leq n; 1\leq j_1\leq j_2\leq m) $ elements $ a_{ij} $ of this matrix, such that $ i_1\leq i\leq i_2 $ and $ j_1\leq j\leq j_2 $ . Sonya states that a submatrix is beautiful if we can independently reorder the characters in each row (not in column) so that all rows and columns of this submatrix form palidroms. Let's recall that a string is called palindrome if it reads the same from left to right and from right to left. For example, strings $ abacaba, bcaacb, a $ are palindromes while strings $ abca, acbba, ab $ are not. Help Sonya to find the number of beautiful submatrixes. Submatrixes are different if there is an element that belongs to only one submatrix.输入输出格式
输入格式
The first line contains two integers $ n $ and $ m $ $ (1\leq n, m\leq 250) $ — the matrix dimensions. Each of the next $ n $ lines contains $ m $ lowercase Latin letters.
输出格式
Print one integer — the number of beautiful submatrixes.
输入输出样例
输入样例 #1
1 3
aba
输出样例 #1
4
输入样例 #2
2 3
aca
aac
输出样例 #2
11
输入样例 #3
3 5
accac
aaaba
cccaa
输出样例 #3
43