#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 SS of length nn. Initially, T0=ST_0 = S. Each time, you may delete a character from the beginning or the end of TiT_i to obtain a new string Ti+1T_{i+1}. After n1n - 1 operations, we will obtain a string Tn1T_{n-1} with only one character. Depending on the choice of deletion each time, there are a total of 2n12^{n-1} 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 TT, let occ(T)\operatorname{\textit{occ}}(T) denote the number of times TT occurs in SS 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 998244353998244353.

Input Format

A single line containing a string SS, 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 2020 test points.

  • For test points 151 \sim 5, S5000|S| \le 5000.
  • For test points 686 \sim 8, each character of SS is generated independently and uniformly at random from a\texttt a and b\texttt b.
  • For test points 9149 \sim 14, S6×104|S| \le 6 \times 10^4.

For all testdata, 1S1051 \le |S| \le 10^5. SS contains only lowercase English letters.

Translated by ChatGPT 5