#P9778. [HUSTFC 2023] 基因编辑
[HUSTFC 2023] 基因编辑
Problem Description
Qiyue has DNA base sequences . Each base sequence can be represented as a string containing only the four uppercase letters A, C, G, and T.
Qiyue can splice two DNA base sequences. The specific operation is: take a prefix (possibly empty) of the first sequence and concatenate it with a suffix (possibly empty) of the second sequence. For example, splicing ACGC and CTAT may produce ACGCTAT, ACGCCTAT, ACAT, or T.
Based on this, Qiyue defines that a triple is good if and only if , , , and splicing and can produce .
Qiyue wants to know the number of good triples.
Input Format
The first line contains an integer , representing the number of base sequences.
The next lines each contain a string. The -th string defines the base sequence . It is guaranteed that .
Output Format
Output one integer, representing the number of good triples.
3
AAA
AA
AA
12
3
ACGC
CTAT
ACAT
1
4
A
C
T
G
0
Hint
Translated by ChatGPT 5