Fuzzy Search

题意翻译

给出一个门限值 $k$ 和两个只包含 $\texttt{AGCT}$ 四种字符的基因串 $S$ 和 $T$。现在你要找出在下列规则中 $T$ 在 $S$ 中出现了几次。 $T$ 在 $S$ 的第 $i$ 个位置中出现,当且仅当把 $T$ 的首字符和 $S$ 的第 $i$ 个字符对齐后,$T$ 中的每一个字符能够在 $S$ 中找到一个位置偏差不超过 $k$ 的相同字符。 即对于所有的 $j \in[1,|T|]$,都存在一个 $p \in [1,|S|]$ 使得 $|(i+j-1)-p| \leq k$ 且 $S_p=T_j$ 。 例如 $k=1$ 时,$\texttt{ACAT}$ 出现在 $\texttt{AGCAATTCAT}$ 的 $2$ 号, $3$ 号和 $6$ 号位置。 (编号从 $1$ 开始。) #### 输入格式 第一行有三个整数 $n$ , $m$ , $k$ ,表示 $S$ 的长度, $T$ 的长度和"门限值"。 第二行给出基因串$S$,第三行给出基因串$T$,且两个串都只包含大写字母$\texttt{ATGC}$ 。 $1≤n≤m≤2*10^5\ ,\ 0≤k≤2*10^5$ #### 输出格式 输出一个整数,表示 $T$ 在 $S$ 中出现的次数。

题目描述

Leonid works for a small and promising start-up that works on decoding the human genome. His duties include solving complex problems of finding certain patterns in long strings consisting of letters 'A', 'T', 'G' and 'C'. Let's consider the following scenario. There is a fragment of a human DNA chain, recorded as a string $ S $ . To analyze the fragment, you need to find all occurrences of string $ T $ in a string $ S $ . However, the matter is complicated by the fact that the original chain fragment could contain minor mutations, which, however, complicate the task of finding a fragment. Leonid proposed the following approach to solve this problem. Let's write down integer $ k>=0 $ — the error threshold. We will say that string $ T $ occurs in string $ S $ on position $ i $ ( $ 1<=i<=|S|-|T|+1 $ ), if after putting string $ T $ along with this position, each character of string $ T $ corresponds to the some character of the same value in string $ S $ at the distance of at most $ k $ . More formally, for any $ j $ ( $ 1<=j<=|T| $ ) there must exist such $ p $ ( $ 1<=p<=|S| $ ), that $ |(i+j-1)-p|<=k $ and $ S[p]=T[j] $ . For example, corresponding to the given definition, string "ACAT" occurs in string "AGCAATTCAT" in positions $ 2 $ , $ 3 $ and $ 6 $ . ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF528D/94e8b565054910853332d9fa2d300b5b4238dda2.png)Note that at $ k=0 $ the given definition transforms to a simple definition of the occurrence of a string in a string. Help Leonid by calculating in how many positions the given string $ T $ occurs in the given string $ S $ with the given error threshold.

输入输出格式

输入格式


The first line contains three integers $ |S|,|T|,k $ ( $ 1<=|T|<=|S|<=200000 $ , $ 0<=k<=200000 $ ) — the lengths of strings $ S $ and $ T $ and the error threshold. The second line contains string $ S $ . The third line contains string $ T $ . Both strings consist only of uppercase letters 'A', 'T', 'G' and 'C'.

输出格式


Print a single number — the number of occurrences of $ T $ in $ S $ with the error threshold $ k $ by the given definition.

输入输出样例

输入样例 #1

10 4 1
AGCAATTCAT
ACAT

输出样例 #1

3

说明

If you happen to know about the structure of the human genome a little more than the author of the problem, and you are not impressed with Leonid's original approach, do not take everything described above seriously.