![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
后缀自动机
a1214034447
这个作者很懒,什么都没留下…
展开
-
SPOJ - LCS 后缀自动机
题解思路:入门后缀自动机题目,只要把一个串建成后缀自动机,然后另一个串在上面跑就行了#include<bits/stdc++.h>using namespace std;typedef long long ll;const int mx = 3e5 + 10;char str[mx],Ts[mx];struct state{ int fa,len;//fa为包含该转态的最...原创 2018-04-09 21:15:44 · 248 阅读 · 0 评论 -
SPOJ - LCS2 后缀自动机
解题思路:多个串的最长公共子串后缀自动机,把一个串建成树,因为根节点到每个节点都是他的子串,那么去取每个节点也就是该串的每个子串与其他串的相同长度,用mn[i]表示该节点表示的子串和其他串相同的最小长度,然后最后取从1-tot节点中取max就可以了。#include<bits/stdc++.h>#define inf 0x3f3f3f3fusing namespace std;t...原创 2018-04-09 21:22:01 · 349 阅读 · 2 评论 -
HYSBZ - 3998 - 后缀自动机
解题思路:由后缀自动机原理可知,由根节点到某一个节点的任意路径形成的串,它们的重复出现次数是相同的。代码有注释#include<bits/stdc++.h>using namespace std;typedef long long ll;const int mx = 1e6 + 10;char str[mx],Ts[mx];struct state{ int fa,len...原创 2018-04-10 19:30:37 · 172 阅读 · 0 评论 -
SPOJ - SUBLEX 后缀自动机
解题思路:不重复的计算子串很简单,只要记忆化搜索,dp过去求每个节点后面有多少个串,然后用逼近法,去求出那个串就行了。#include<bits/stdc++.h>using namespace std;typedef long long ll;const int mx = 2e5 + 10;char str[mx],Ts[mx];struct state{ int fa...原创 2018-04-10 19:36:34 · 204 阅读 · 0 评论 -
poj 1743 - 后缀自动机或后缀数组
后缀自动机:利用right集合的包含关系,利用一开始的原串的前缀串的最右端,去更新其他点right集合右端点包含它的子串出现的右端点位置,然后用最大位置减去最小位置和l【i】的关系看是否有重复#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#defin...原创 2018-04-11 16:09:59 · 219 阅读 · 0 评论 -
是男人就过 8 题--Pony - A - 后缀自动机+SG函数
题目链接:点击打开链接解题思路:在后缀自动机的有向图上建立SG函数,然后去求每个子串在树上的节点号,异或个各个节点号sg值就行了。#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#define inf 0x3f3f3f3fusing namespac...原创 2018-04-11 16:50:58 · 393 阅读 · 0 评论 -
SPOJ - HACKING - 后缀自动机
题目链接:https://vjudge.net/problem/SPOJ-HACKING 解题思路:建个后缀自动机,然后在树上跑前K个字符的dfs,直到遇到树上没有的即停止.算法复杂度O(n*m) #include<bits/stdc++.h>#define inf 0x3f3f3f3fusing namespace std;const int mx =...原创 2018-10-30 20:18:04 · 136 阅读 · 0 评论