#P3763. [TJOI2017] DNA

    ID: 1388 远端评测题 1000ms 500MiB 尝试: 10 已通过: 1 难度: 8 上传者: 标签>2017各省省选RMQ后缀数组,SA快速傅里叶变换 FFT天津

[TJOI2017] DNA

Description

Researchers at the Biology Institute of Garitun University discovered a gene sequence SS that determines whether a person likes eating lotus root. Any DNA segment with this sequence exhibits the "likes lotus root" trait. Moreover, they found that for the base sequence SS, modifying at most 33 bases still results in the trait. Now the researchers want to locate this gene on a DNA strand S0S_0. Therefore, you need to count, on the DNA sequence S0S_0 of a person who exhibits the trait, how many contiguous substrings could be this gene, i.e., how many contiguous substrings of S0S_0 can be changed into SS by modifying at most three letters.

Input Format

The first line contains an integer TT, the number of test cases.

For each test case, the first line contains a base sequence S0S_0 of length not exceeding 10510^5.

The second line contains the "lotus-root gene" sequence SS of length not exceeding 10510^5.

Output Format

Output TT lines. The ii-th line indicates, in the ii-th test case, how many contiguous substrings in S0S_0 of the same length as SS could be a base sequence exhibiting the "likes lotus root" trait.

1
ATCGCCCTA
CTTCA
2

Hint

For 20%20\% of the testdata, the lengths of S0S_0 and SS do not exceed 10410^4.

For 100%100\% of the testdata, the lengths of S0S_0 and SS do not exceed 10510^5, 0<T100\lt T\leq 10.

Note: DNA base sequences only contain the four characters A, T, C, and G.

Translated by ChatGPT 5