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…
这道题和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…
思路: 论文题- 二分+对后缀分组 这块一开始不用基数排序 会更快的(其实区别不大) //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…
题意: 求可重叠的最长重复子串,但有一个限制条件..要至少重复k次 解析: 二分枚举k,对于连续的height 如果height[i] >= k 说明它们至少有k个元素是重复的,所以判断一下就好了 数据很水 输入数据可能为0,所以s[i]++  s[n++] = 0; 要后缀数组要保证末尾加的字符比前面的都小 这是百度百科上的..这里的r数组即为s数组 #include <iostream> #include <cstdio> #include <sstream>…
题目链接:http://poj.org/problem?id=3261 题意:约翰注意到奶牛产奶的之类是不断变化的,虽然他不能预测从当天到下一天的变化情况但是他知道变化是有规律的,牛奶的质量由一个整数表示,范围从0到1000000,现在给定一个长度为n的序列,要求找到一个最大子序列,该子序列重复出现至少k次,各个出现部分可有重叠,求最长的长度.简单来说就是可重叠的k 次最长重复子串. 思路:直接根据09年oi论文<<后缀数组——出来字符串的有力工具>>的解法,先二分答案x,然后将后…
题目:http://poj.org/problem?id=3261 仍然是后缀数组的典型应用----后缀数组+lcp+二分 做的蛮顺的,1A 可是大部分时间是在调试代码.由于模板的全局变量用混了,而自己又忘了.,,等西安邀请赛还有四省赛结束之后,该冷静反思下尝试拜托模板了 错误   :1.k用错,题目的k和模板的k用混; 2.还是二分的C()函数,这个事实上跟前一篇<poj 1226 hdu 1238 Substrings 求若干字符串正串及反串的最长公共子串 2002亚洲赛天津预选题>的C函…
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,…
Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 35607   Accepted: 14275 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…
题目大意:给你一个数组,求这个数组里面至少重复k次的子串.   分析:后缀数组的练手题目...不过给的数字比较大,可以先离散化处理一下即可.   代码如下: =============================================================================================================================== #include<stdio.h> #include<string.h>…
Milk Patterns Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 9274   Accepted: 4173 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,…