#P8643. [蓝桥杯 2016 国 AC] 碱基
[蓝桥杯 2016 国 AC] 碱基
Problem Description
Biologists are studying species.
For the -th species, its DNA sequence is . The -th base is , 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 that appear in at least species. More precisely, the sequences that the scientists care about are represented by a -tuple , which satisfies:
and for all ,
$$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 -tuples need to be considered. If two -tuples differ at any position, they are considered different tuples.
Input Format
The first line contains three integers , , , separated by one space, with meanings as described above.
The next lines each contain a string representing the DNA sequence of one species.
The DNA sequences are numbered from to . Within each sequence, bases are numbered starting from 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 .
3 2 2
ATC
TCG
ACG
2
4 3 3
AAA
AAAA
AAA
AAA
7
Hint
Constraints
For of the testdata, and the total length of all strings satisfies .
For of the testdata, .
For of the testdata, .
For of the testdata, .
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