随笔分类 -  字符串---SAM后缀自动机

摘要:题:http://acm.hdu.edu.cn/showproblem.php?pid=6194 题意:求出现恰好k次的子串数量 分析:也就是f数组==k的maxlen[i]-maxlen[ slink[i] ]的总和; 因为f数组表示endpos的集合大小,也就是状态在多少个位置出现过,那么这个状 阅读全文
posted @ 2020-12-09 22:46 starve_to_death 阅读(123) 评论(0) 推荐(0)
摘要:题:http://acm.hdu.edu.cn/showproblem.php?pid=4622 题意:求[u,v]区间内有多少不同的子串,N<=2000,q<=10000 分析:建立i....n个字符串的SAM,就可以预处理各个区间字符串的数目。 #include<iostream> #inclu 阅读全文
posted @ 2020-07-21 14:53 starve_to_death 阅读(135) 评论(0) 推荐(0)
摘要:题:https://ac.nowcoder.com/acm/contest/5669/C 题解: 分析:核心点1:当我们把原串第一次进行f函数后,第二次的f函数一定是对第一次经过f函数后的串进行取子串。 核心点2:因为f函数的特性,这n个子串我们可以以10(字符集)*N的节点代价来建立字典树,考虑题 阅读全文
posted @ 2020-07-21 14:20 starve_to_death 阅读(184) 评论(0) 推荐(0)
摘要:求字符串子串种类数 题:http://hihocoder.com/problemset/problem/1445 分析:后缀自动机模板 #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> using na 阅读全文
posted @ 2020-07-05 13:44 starve_to_death 阅读(158) 评论(0) 推荐(0)