#P8643. [蓝桥杯 2016 国 AC] 碱基

    ID: 7699 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP2016哈希 hashing蓝桥杯国赛

[蓝桥杯 2016 国 AC] 碱基

Problem Description

Biologists are studying nn species.

For the ii-th species, its DNA sequence is s[i]s[i]. The jj-th base is s[i][j]s[i][j], and every base must be one of A, G, C, T.

The biologists want to find some common features among a subset of these species. They are now focusing on contiguous base sequences of length kk that appear in at least mm species. More precisely, the sequences that the scientists care about are represented by a 2m2m-tuple (i1,p1,i2,p2,im,pm)(i_1,p_1,i_2,p_2 \cdots ,i_m,p_m), which satisfies:

1i1<i2<<imn1 \le i_1<i_2< \cdots <i_m \le n

and for all q(0q<k)q(0 \le q<k),

$$s[i_1][p_1+q]=s[i_2][p_2+q]= \cdots =s[i_m][p_m+q]$$

Now, given the DNA sequences of all species, tell the scientists how many such 2m2m-tuples need to be considered. If two 2m2m-tuples differ at any position, they are considered different tuples.

Input Format

The first line contains three integers nn, mm, kk, separated by one space, with meanings as described above.

The next nn lines each contain a string representing the DNA sequence of one species.

The DNA sequences are numbered from 11 to nn. Within each sequence, bases are numbered starting from 11 in order. The DNA sequence lengths of different species may be different.

Output Format

Output one integer, the number of tuples to be considered.

The answer may be very large. You need to output the remainder of the answer modulo 1000000007(109+7)1000000007(10^9+7).

3 2 2
ATC
TCG
ACG
2
4 3 3
AAA
AAAA
AAA
AAA
7

Hint

Constraints

For 20%20\% of the testdata, k5,k \le 5, and the total length LL of all strings satisfies L100L \le 100.

For 30%30\% of the testdata, L10000L \le 10000.

For 60%60\% of the testdata, L30000L \le 30000.

For 100%100\% of the testdata, n5,m5,1kL105n \le 5,m \le 5,1 \le k \le L \le 10^5.

It is guaranteed that all DNA sequences are non-empty and contain only the four letters A, G, C, T.

Time limit: 1 second, 256 MB. Lanqiao Cup 2016, 7th National Final.

Translated by ChatGPT 5