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

建议使用的浏览器:

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

7102:Pattern Recognition

题目描述
Given an image consisting only lowercase letters, for each query you should count the number of patterns in the image.

Formally, an image is a matrix with $n$ rows and $m$ columns, and each cell of the matrix contains a character. Considering a string consisting of lowercase letters, we can place it horizontally or vertically, so it has following shapes:

We can bend it $90$ degrees, and we get some new shapes:

In a word, a pattern is a string with these $6$ possible shapes:

For example, pattern abcd can have following shapes:

Kanari loves CV(Computer Vision), he writes a CNN(Convolutional Neural Network) to count the number of patterns in an image. Kanari is so cute, and the accuracy tends to $100\%$ after a long time parameter adjustment. Can you solve it too?
输入解释
This problem contains multiple test cases.

The first line of the input contains an integer $T (1 \leq T \leq 5)$ indicating the number of test cases.

For each test case, the first line contains three integers $n, m, q (n \geq 1, m \geq 1, 1 \leq n \times m \leq 10^5)$, representing the width of the image, the height of the image and the number of queries.

Each of the next $n$ lines contains $m$ characters representing the image.

Each of the next $q$ lines contains a string representing a query.

It is guaranteed that the sum of length of all queries in a test case is no more than $10^5$.
输出解释
For each query, output the number of corresponding patterns occurred in the image. Note that two occurences are different if and only if the SET of positions for the pattern in the image are different.
输入样例
2
10 10 1
xxxxxxxxxx
xbcdxxxxxx
xaxxxdcbax
xxxdxxxxxx
xxxcbaxxxx
xxxxxxabxx
xaxaxxdcxx
xbxbxxxxdc
xcxcxxxxxb
xdxdxxxxxa
abcd
5 5 2
xsssx
xxbxx
xbabx
xxbxx
xxxxx
ab
sss
输出样例
6
4
1
来自杭电HDUOJ的附加信息
Hint Explanation for the second testcase:For pattern ab , the occurences are { (2, 3), (3, 3) }, { (3, 2), (3, 3) }, { (3, 3), (3, 4) }, { (3, 3), (4, 3) }.For pattern sss , the only occurence is { (1, 2), (1, 3), (1, 4) }.

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

源链接: HDU-7102

最后修改于 2021-10-23T19:11:26+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
20000/12000MS(Java/Others) 786432/786432K(Java/Others)