正文
增加 9 行删除 9 行
138 行未改动全部展开1391401411421431441451461471481491501511521531548 行未改动16316416516616716816917017117217317417568 行未改动24424524624724824925025125225319 行未改动2732742752762772782792802812 行未改动284285286287288289290291292270 行未改动全部展开138 行未改动全部展开// just means the length increases by 1lenth[u] = lenth[p] + 1; sz[u] = 1;/** @brief* if the suffix of the original string* add a new character @p c hasn't appeared yet,* then we connect the represent node with the new node,* it means that we can get a new class if we add @p c to the end*/for(; p && !tre[p][c]; p = fa[p]) tre[p][c] = u;/** @brief* if all suffixes haven't appeared before after adding @p c* we'll reach the situation where @p p equals to 0,* which means the father of the new class is 1(root)*/if(!p) fa[u] = 1;/** @brief if the situation is not like this8 行未改动* some suffixes of @p q will appear at n,* in other words, some part of @p q will add END POINT @p n (present length),* which will make a different to class @p q and* cause the split of class @p q.* We're going to judge whether @p q should be split or not,* if the answer is true, we're supposed to handle the split*/int q = tre[p][c];/** @brief* if all suffix have appeared before after adding @p c ,* then there's no need to split class @p q ,* because add END POINT will add n(present length)* we just need to connect the new class @p u with it father68 行未改动```cpp/** @brief* if the suffix of the original string* add a new character @p c hasn't appeared yet,* then we connect the represent node with the new node,* it means that we can get a new class if we add @p c to the end*/for(; p && !tre[p][c]; p = fa[p]) tre[p][c] = u;```19 行未改动* some suffixes of @p q will appear at n,* in other words, some part of @p q will add END POINT @p n (present length),* which will make a difference to class @p q and* cause the split of class @p q.* We're going to judge whether @p q should be split or not,* if the answer is true, we're supposed to handle the split*/int q = tre[p][c];```2 行未改动同时,对于 $\tt q$,由于它和 $\tt p$ 并非有实际父子关系,而是由自动鸡连接的 ~~你居然不是我亲生的~~,也就是说 $\tt q$ 代表的串并非全是原串 $S$ 的后缀(但一定会有一个 $S$ 的后缀,即在 $\tt p$ 所代表的后缀之后加上一个 $\tt c$ 的后缀 ),但是我们找到它的原因是什么——它其中的某些串在 $S$ 加上 $\tt c$ 之后,会在 $|S|+1$ 再出现一次,也就是有些串的 $\text{endpos}$ 就会改动,同样的,$\tt q$ 中有些串又不会改动,这下出了个问题——$\tt q$ 所代表的类中的串的 $\text{endpos}$ 集合不一样了,根据定义已经不能再将他们归为同一类,所以接下来我们要考虑将 $\tt q$ 分裂——加上 $|S|+1$ 的部分,和没有加上 $|S|+1$ 的部分;```cpp/** @brief* if all suffix have appeared before after adding @p c ,* then there's no need to split class @p q ,* because add END POINT will add n(present length)* we just need to connect the new class @p u with it father270 行未改动全部展开138 行未改动全部展开1391401411421431441451461471481491501511521531548 行未改动16316416516616716816917017117217317417568 行未改动24424524624724824925025125225319 行未改动2732742752762772782792802812 行未改动284285286287288289290291292270 行未改动全部展开138 行未改动全部展开// just means the length increases by 1lenth[u] = lenth[p] + 1; sz[u] = 1;/** @brief* if the suffix of the original string* add a new character @p c hasn't appeared yet,* then we connect the represent node with the new node,* it means that we can get a new class if we add @p c to the end*/for(; p && !tre[p][c]; p = fa[p]) tre[p][c] = u;/** @brief* if all suffixes haven't appeared before after adding @p c* we'll reach the situation where @p p equals to 0,* which means the father of the new class is 1(root)*/if(!p) fa[u] = 1;/** @brief if the situation is not like this8 行未改动* some suffixes of @p q will appear at n,* in other words, some part of @p q will add END POINT @p n (present length),* which will make a different to class @p q and* cause the split of class @p q.* We're going to judge whether @p q should be split or not,* if the answer is true, we're supposed to handle the split*/int q = tre[p][c];/** @brief* if all suffix have appeared before after adding @p c ,* then there's no need to split class @p q ,* because add END POINT will add n(present length)* we just need to connect the new class @p u with it father68 行未改动```cpp/** @brief* if the suffix of the original string* add a new character @p c hasn't appeared yet,* then we connect the represent node with the new node,* it means that we can get a new class if we add @p c to the end*/for(; p && !tre[p][c]; p = fa[p]) tre[p][c] = u;```19 行未改动* some suffixes of @p q will appear at n,* in other words, some part of @p q will add END POINT @p n (present length),* which will make a difference to class @p q and* cause the split of class @p q.* We're going to judge whether @p q should be split or not,* if the answer is true, we're supposed to handle the split*/int q = tre[p][c];```2 行未改动同时,对于 $\tt q$,由于它和 $\tt p$ 并非有实际父子关系,而是由自动鸡连接的 ~~你居然不是我亲生的~~,也就是说 $\tt q$ 代表的串并非全是原串 $S$ 的后缀(但一定会有一个 $S$ 的后缀,即在 $\tt p$ 所代表的后缀之后加上一个 $\tt c$ 的后缀 ),但是我们找到它的原因是什么——它其中的某些串在 $S$ 加上 $\tt c$ 之后,会在 $|S|+1$ 再出现一次,也就是有些串的 $\text{endpos}$ 就会改动,同样的,$\tt q$ 中有些串又不会改动,这下出了个问题——$\tt q$ 所代表的类中的串的 $\text{endpos}$ 集合不一样了,根据定义已经不能再将他们归为同一类,所以接下来我们要考虑将 $\tt q$ 分裂——加上 $|S|+1$ 的部分,和没有加上 $|S|+1$ 的部分;```cpp/** @brief* if all suffix have appeared before after adding @p c ,* then there's no need to split class @p q ,* because add END POINT will add n(present length)* we just need to connect the new class @p u with it father270 行未改动全部展开