SAM详解2(初级应用)

SAM

5. 初级应用

  • l o n g e s t ( x ) longest(x) longest(x) 为点 x x x 代表子串集合中最长串的长度。
  • s h o r t e s t ( x ) shortest(x) shortest(x) 为点 x x x 代表子串集合中最短串的长度。
  • s z x sz_x szx 为点 x x x 代表的 e d p edp edp 的大小。
  • 可能用 l e n ( x ) , l e n x , x . l e n len(x),len_x,x.len len(x),lenx,x.len 表示点 x x x 所代表子串集合中最长串的长度, l i n k link link 等也是这样。
  • 其他定义和 SAM详解1一样。

5.1 静态本质不同子串个数

在 parent tree 上,每个节点的 e d p edp edp 集合不同,即代表的子串不同。

则显然有 a n s = ∑ i = 1 l o n g e s t ( i ) − s h o r t e s t ( i ) + 1 ans=\sum_{i=1}longest(i)-shortest(i)+1 ans=i=1longest(i)shortest(i)+1

然后有 s h o r t e s t ( i ) = l o n g e s t ( f a i ) + 1 shortest(i)=longest(fa_i)+1 shortest(i)=longest(fai)+1,其中 f a i fa_i fai i i i 的父节点。

替换,则有 a n s = ∑ i = 1 l o n g e s t ( i ) − l o n g e s t ( f a i ) ans=\sum_{i=1}longest(i)-longest(fa_i) ans=i=1longest(i)longest(fai),或者 a n s = ∑ i = 1 l e n ( i ) − l e n ( l i n k ( i ) ) ans=\sum_{i=1}len(i)-len(link(i)) ans

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值