![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
字符串
文章平均质量分 63
如题
Edward The Bunny
这个作者很懒,什么都没留下…
展开
-
[XSY3320] string (AC自动机,哈希,点分治)
前置芝士:回文前缀&&borderborderborder推荐博客推荐博客考虑点分治,问题变成求经过重心的回文路径个数。一条经过重心的回文路径长这样:xxx到zzz的串与yyy到rootrootroot的串相同。建出根到每个节点对应的串的AC自动机,并在failfailfail树上找出每个串的回文前缀。判断根到某个节点对应的串是不是回文串可以用哈希解决。根据borderborderborder理论,一个回文串的所有回文前缀的长度可以组成一个不超过O(logn)O(logn)O原创 2021-09-30 13:35:39 · 128 阅读 · 0 评论 -
[XSY] 字符串题(字符串,构造)
字符串题考虑找到一种方法,能够对一个 lyndon 串 A ,直接求出 A 的下一个 lyndon 串。若 A 是 lyndon 串,则 AAA…A 也是 lydon 串证明:设 A=a1a2⋯a∣A∣A=a_1a_2⋯a_{|A|}A=a1a2⋯a∣A∣ ,由于 A 为 lyndon 串,所以对 ∀1<i≤∣A∣∀1<i≤|A|∀1<i≤∣A∣ ,有 aiai+1⋯a∣A∣a1a2...ai−1>a1a2⋯a∣A∣a_ia_{i+1}⋯a_{|A|}a_1a_2.原创 2021-03-16 20:26:34 · 199 阅读 · 0 评论 -
[XSY] 宝藏(LCS,DP)
宝藏首先,这个问题等价于给定两个字符串S,T ,每次询问LCS(S[1,n],T[x,y])LCS(S[1,n],T[x,y])LCS(S[1,n],T[x,y])。对每个询问重新求一遍LCSLCSLCS显然不现实,又因为x,yx,yx,y都是连续变化的,我们考虑探讨LCS(S[1,n],T[x,y])LCS(S[1,n],T[x,y])LCS(S[1,n],T[x,y])与LCS(S[1,n],T[x,y−1])LCS(S[1,n],T[x,y-1])LCS(S[1,n],T[x,y−1])的关系原创 2021-03-10 14:44:02 · 148 阅读 · 0 评论 -
[XSY] 最长公共子串对(后缀自动机)
先放一段考场暴力代码:#include<iostream>#include<cstdio>#include<cstring>using namespace std;char a[2005],b[2005];int na,nb,f[2005][2005],c[2005][2005],ans;//f[i][j]表示s[1...i]与t[1...j]以s[i]、t[j]结尾的最长公共子串长度int lowbit(int x){ return x&原创 2021-03-09 20:24:21 · 224 阅读 · 0 评论 -
AC自动机
有什么用:处理多个字符串的问题算法实现:#include<bits/stdc++.h>using namespace std;string a[300010];int num[300010],tr[300010][26],fail[300010],ans[300010];int tmp,n,cnt;void insert(string s,int id){ int now=0; for(int i=0;i<s.size();i++){ int原创 2021-03-08 21:19:03 · 80 阅读 · 0 评论 -
字符串(AC自动机(fail tree))
传送门注意:注释中的那段代码是不能用的#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<queue>using namespace std;typedef long long ll;const int N=2000010;struct Edge{int v,nxt;}edge[N];int head[N],cnt;int ch原创 2021-03-05 21:36:53 · 139 阅读 · 0 评论