lcp(Ti,Tj)=min{hi,⋯,hj}
因此考虑
hi
对于其在
h
<script type="math/tex" id="MathJax-Element-107">h</script>上所能向左向右延伸的区间内的所有lcp都是其答案。因此参考poj 2796。。
代码稍后
3238: [Ahoi2013]差异
Time Limit: 20 Sec Memory Limit: 512 MB
Submit: 1342 Solved: 621
[Submit][Status][Discuss]
Description
Input
一行,一个字符串S
Output
一行,一个整数,表示所求值
Sample Input
cacao
Sample Output
54
HINT
2<=N<=500000,S由小写英文字母组成