题目:http://poj.org/problem?id=3261 仍然是后缀数组的典型应用----后缀数组+lcp+二分 做的蛮顺的,1A 可是大部分时间是在调试代码.由于模板的全局变量用混了,而自己又忘了.,,等西安邀请赛还有四省赛结束之后,该冷静反思下尝试拜托模板了 错误   :1.k用错,题目的k和模板的k用混; 2.还是二分的C()函数,这个事实上跟前一篇<poj 1226 hdu 1238 Substrings 求若干字符串正串及反串的最长公共子串 2002亚洲赛天津预选题>的C函…
题目链接:http://poj.org/problem?id=3261 题意:约翰注意到奶牛产奶的之类是不断变化的,虽然他不能预测从当天到下一天的变化情况但是他知道变化是有规律的,牛奶的质量由一个整数表示,范围从0到1000000,现在给定一个长度为n的序列,要求找到一个最大子序列,该子序列重复出现至少k次,各个出现部分可有重叠,求最长的长度.简单来说就是可重叠的k 次最长重复子串. 思路:直接根据09年oi论文<<后缀数组——出来字符串的有力工具>>的解法,先二分答案x,然后将后…
Farmer John has noticed that the quality of milk given by his cows varies from day to day. On further investigation, he discovered that although he can't predict the quality of milk from one day to the next, there are some regular patterns in the dai…
题意:求最少重叠\(k\)次的重复子串的最大长度 子串长度问题依然是二分枚举,可以观察出重叠的一定是sa排序中连续的 之前想出一种判断要\(n^2\)的方法,没有考虑到后面肯定会连续出现的情况 (大概想法是枚举重复中的最大\(lcp\)(和之前定义的\(lcp\)有所区别),若存在\(k\)个\((i-j)<=lcp\)既为真←好像很不靠谱的样子) #include<iostream> #include<algorithm> #include<cstdio> #i…
Milk Patterns Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 16430   Accepted: 7252 Case Time Limit: 2000MS Description Farmer John has noticed that the quality of milk given by his cows varies from day to day. On further investigation,…
这道题和UVa 12206一样,求至少重复出现k次的最长字串. 首先还是二分最长字串的长度len,然后以len为边界对height数组分段,如果有一段包含超过k个后缀则符合要求. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; + ; + ; int s[maxn]; int sa[maxn], height[maxn], rank[maxn]; int t[m…
题目链接:http://poj.org/problem?id=3261 这个是可以交叉的重复串,所以用height就可以了,但是题目说让重复k次以上,也就是直接做一个k-1长度的滑窗最小值,从这些最小值里取最大即可. 这里其实为了节省空间可以先给数字离散化一下,这样就只有20000了,不过不离散化空间也够用. #include<cstdio> #include<algorithm> #include<cstring> #include<queue> usin…
思路: 论文题- 二分+对后缀分组 这块一开始不用基数排序 会更快的(其实区别不大) //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define N 20050 int n,k,s[N],cntA[N],cntB[N],A[N],B[N],rk[N],sa[N],tsa[N],ht[N]; struct Node{int pos…
Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 31904   Accepted: 12876 Case Time Limit: 1000MS Description The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days…
题目链接:http://poj.org/problem?id=3415 题意:给定2个串[A串和B串],求两个串公共子串长度大于等于k的个数. 思路:首先是两个字符串的问题.所以想用一个'#'把两个字符串拼接起来.求后缀数组. 然后按照k把height数组分组.大于等于k的为一组,然后就是统计每组的贡献.对于每一组的贡献即是组内所有A串的后缀和B串的后缀的lcp值,即为val.那么val对于答案的贡献为(val-k+1).如果我们暴力每组的AB串后缀的组合.时间复杂度是O(n^2).不能满足要求…