
后缀数组
吴俊达9812
这个作者很懒,什么都没留下…
展开
-
luogu P1117( lcp 模板 )
题意:给你一个字符串,问你有多少个子串,形式是AABB AABBAABB,其中A AA和B BB可以相同。串长 <=30000,对于同一个字符串,不同的拆分属于不同的方案。思路:对于形式为AABB的字串,我们考虑枚举A和B之间的断点,再使用乘法原理进行计算。 接下来我们考虑如何计算以某一个位置为开始和某一位置为结尾的AA的方案数。 首先我们枚...原创 2019-10-11 22:35:54 · 139 阅读 · 0 评论 -
luogu P2852 [USACO06DEC]牛奶模式Milk Patterns
指针又一次被我写挂了。。(一定要记得循环出去后一定得更新一下答案)#include <bits/stdc++.h>using namespace std;typedef long long LL;typedef int lint;const lint maxn = 20005;const lint log_maxn = 20;typedef int lint;str...原创 2019-08-28 23:29:56 · 9369 阅读 · 0 评论 -
2019 ccpc 网络赛 K-th occurrence(排名lcp模板)
题意:查询子串在原串中第k次出现的位置思路: ST表 + 主席树 + 后缀数组#include <bits/stdc++.h>using namespace std;typedef long long LL;typedef int lint;const lint maxn = 100000 + 10;const lint log_maxn = 20;typedef...原创 2019-08-23 18:32:15 · 357 阅读 · 0 评论 -
hdu 6194 string string string
容斥原理+后缀数组。后缀数组上的计数问题总考,这种方法应该引起重视。#include <bits/stdc++.h>using namespace std;typedef long long LL;typedef int lint;const lint maxn = 500000 + 10;typedef int lint;struct suffix{ l...原创 2019-06-26 21:15:03 · 109 阅读 · 0 评论 -
焦作网络赛 H. String and Times(后缀数组+容斥原理)
查询出现次数大于k次的子串有多少个。根据后缀的排名,顺序统计每个后缀有多少个前缀满足条件,满足条件的个数减去与上一个排名相重合的。#include <bits/stdc++.h>using namespace std;typedef long long LL;typedef int lint;const lint maxn = 500000 + 10;typede...原创 2019-06-26 21:05:25 · 250 阅读 · 0 评论 -
2018 焦作 H. Can You Solve the Harder Problem?
思路:单调栈加后缀数组。有点绕(尼玛又发现了后缀数组板子的bugQAQ),如果全是 0 g.s 的初始化也为0,求h数组就凉了//本质不同的子串个数#include <bits/stdc++.h>using namespace std;typedef long long LL;typedef int lint;const lint maxn = 2000000 + 1...原创 2019-06-09 14:38:57 · 642 阅读 · 0 评论 -
URAL 1297 最长回文子串(LCP模板)
//最长回文子串 , lcp 模板#include <bits/stdc++.h>using namespace std;typedef long long LL;typedef int lint;const lint maxn = 2000 + 10;typedef int lint;struct suffix{ lint c[maxn],sa[maxn],...原创 2019-06-08 12:04:09 · 198 阅读 · 0 评论 -
distinct substrings
//本质不同的子串个数#include <bits/stdc++.h>using namespace std;typedef long long LL;typedef int lint;const lint maxn = 1000 + 10;typedef int lint;struct suffix{ lint c[maxn],sa[...原创 2019-06-07 13:06:40 · 204 阅读 · 0 评论 -
poj 3261
//最少重叠k次的最长子串#include <vector>#include<cstdio>#include<algorithm>#include<iostream>#include<cstring>using namespace std;typedef long long LL;typedef int...原创 2019-06-07 12:18:37 · 155 阅读 · 0 评论 -
poj 1743
男人8题,又改了一次板子//最长不重叠重复子串#include <cstdio>#include<cstring>#include<iostream>using namespace std;typedef long long LL;typedef int lint;const lint maxn = 20000 + 10;const ...原创 2019-06-06 23:43:49 · 143 阅读 · 0 评论 -
POJ 2774( 后缀数组模板 )
注意 :swap( x[N],y[N] ) 复杂度为O(N),不要直接swap//最长公共子串#include <cstdio>#include<cstring>#include<iostream>using namespace std;typedef long long LL;typedef int lint;c...原创 2019-06-05 21:46:28 · 207 阅读 · 0 评论