#P8351. [SDOI/SXOI2022] 子串统计
[SDOI/SXOI2022] 子串统计
Problem Description
When Xiao D was four and a half years old, he learned the suffix automaton.
You are given a string of length . Initially, . Each time, you may delete a character from the beginning or the end of to obtain a new string . After operations, we will obtain a string with only one character. Depending on the choice of deletion each time, there are a total of possible operation sequences. Note that although for some operation, deleting the first character or the last character may produce the same string, we still treat them as two different operation sequences.
For a string , let denote the number of times occurs in as a substring. For example, $\operatorname{\textit{occ}}(\texttt{aaa},\texttt{aaaabaaa}) = 3$.
For an operation sequence, define its contribution as
$$\prod_{i = 1}^{n - 1} \operatorname{\textit{occ}}(T_i)$$Compute the sum of contributions over all operation sequences. Since the answer can be very large, output the result modulo .
Input Format
A single line containing a string , guaranteed to consist only of lowercase letters.
Output Format
Output one line containing an integer representing the answer.
zzz
24
abbab
53
见附加样例文件中的 ex_substring3.in
见附加样例文件中的 ex_substring3.out
Hint
Constraints
This problem has test points.
- For test points , .
- For test points , each character of is generated independently and uniformly at random from and .
- For test points , .
For all testdata, . contains only lowercase English letters.
Translated by ChatGPT 5