#P4248. [AHOI2013] 差异
[AHOI2013] 差异
Description
Given a string of length , let denote the suffix starting from its -th character. Compute
$$\displaystyle \sum_{1\leqslant i<j\leqslant n}\operatorname{len}(T_i)+\operatorname{len}(T_j)-2\times\operatorname{lcp}(T_i,T_j)$$where denotes the length of string , and denotes the longest common prefix of strings and .
Input Format
One line, a string .
Output Format
One line, an integer representing the required value.
cacao
54
Hint
Constraints
- For of the testdata, it is guaranteed that , and all characters in are lowercase letters.
Translated by ChatGPT 5
京公网安备 11011102002149号