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

建议使用的浏览器:

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

6975:Forgiving Matching

题目描述
Little Q is now checking whether string $A$ matches $B$. Two strings are considered matched if they have the same length, and there is no position $i$ that $A_i$ is different from $B_i$.

However, Little Q is a kind man, he forgives every person who hurt him. What's more, he even forgives strings! He gives the string $k$ opportunities, if there are no more than $k$ positions $i$ that $A_i$ is different from $B_i$, then Little Q will also consider the two strings matched. Note that both of the strings may contain the wildcard character '$\texttt{*}$', which can match exactly one any character, in such a case this pair won't consume the forgiveness opportunities.

Let's denote $occ(S,T)$ as the number of substrings in string $S$ which matches $T$, two substrings are considered different if they start in different places. You will be given two strings $S$ and $T$, write a program to compute the value of $occ(S,T)$ for $k=0,1,2,\dots,|T|$.
输入解释
The first line contains a single integer $K$ ($1 \leq K \leq 100$), the number of test cases. For each test case:

The first line of the input contains two integers $n$ and $m$ ($1 \leq m\leq n \leq 200\,000$), denoting the length of $S$ and the length of $T$.

The second line contains a string $S$ of length $n$.

The third line contains a string $T$ of length $m$.

It is guaranteed that the sum of all $n$ is at most $1\,000\,000$. Both $S$ and $T$ can only contain the characters in $\{$'$\texttt{0}$', '$\texttt{1}$', '$\texttt{2}$', '$\texttt{3}$', '$\texttt{4}$', '$\texttt{5}$', '$\texttt{6}$', '$\texttt{7}$', '$\texttt{8}$', '$\texttt{9}$', '$\texttt{*}$'$\}$.
输出解释
For each test case, output $m+1$ lines, the $i$-th ($1\leq i\leq m+1$) of which containing an integer, denoting the value of $occ(S,T)$ when $k=i-1$.
输入样例
1
5 3
012*4
1*3
输出样例
1
1
3
3

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

源链接: HDU-6975

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

共提交 0

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