当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7222:Undercity

题目描述
$\space \space$*How many times have you died in WarCraft because of falling off the UnderCity's elevator?*

$\space \space $*How many times have you traveled through the labyrinthine city but couldn't find the auction house?*

$\space \space$*Undercity is a maze itself!*


Undercity's map can be seen as an $n \cdot m$ matrix, each cell of the matrix contains a lowercase English letter. A path is a sequence of cells such that two neighbouring cells share one edge and the next cell can be reached from the previous cell by only moving **right or down**.

The city is a little bit weird, so one can only travel through a palindromic path.

A palindromic path is a path such that if you view the letters on all the cells from the starting point to the ending point of the path as a sequence, the sequence is equal when you read from left to right and from right to left.

A way of covering is considered magic if and only if all cells of the matrix are covered by **exactly one** palindromic path.

Two magic coverings are considered different if and only if there is **at least one** cell that is covered by different paths in two ways.

Sylvanas believes it's a fulfilling mission to find the number of magic coverings in the city.

Let's help her to do it!
输入解释
The input consists of multiple test cases.

The first line contains an integer $T\ (1\leq T\leq10)$ denoting the number of test cases.

In each test case, the first line contains two integers $n, m(n,m\leq 6)$, denoting the size of matrix.

The following $n$ lines, each line contains $m$ lowercase English letters, describing the matrix.
输出解释
For each test case, output one line containing one integer, denoting the answer.
输入样例
2
2 2
ab
cd
2 2
aa
aa
输出样例
1
9

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7222

最后修改于 2022-09-15T06:17:28+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
30000/15000MS(Java/Others) 524288/524288K(Java/Others)