问题描述 LG2852 题解 字符串性质:字符串\(s\)的每个字串等于每个后缀的所有前缀 对输入的东西离散化,然后把数值看做\(\mathrm{ASCII}\)后缀排序 二分答案,二分长度. 显然一段相同的字串,一定是连续一段后缀的公共前缀. 如此\(check\)即可. \(\mathrm{Code}\) #include<bits/stdc++.h> using namespace std; #define maxn 20007 void read(int &x){ x=0;ch…
题意:给定一个字符串,求至少出现k 次的最长重复子串,这k 个子串可以重叠. 分析:经典的后缀数组求解题:先二分答案,然后将后缀分成若干组.这里要判断的是有没有一个组的符合要求的后缀个数(height[i] >= mid)不小于k.如果有,那么存在 k 个相同的子串满足条件,否则不存在. #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> using…
Milk Patterns Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7938   Accepted: 3598 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,…
题目题目:http://poj.org/problem?id=3261 Milk Patterns Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 18880 Accepted: 8336 Case Time Limit: 2000MS Description Farmer John has noticed that the quality of milk given by his cows varies from day t…
Milk Patterns Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 16742   Accepted: 7390 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,…
#2033. 「SDOI2016」生成魔咒     题目描述 魔咒串由许多魔咒字符组成,魔咒字符可以用数字表示.例如可以将魔咒字符 1 11.2 22 拼凑起来形成一个魔咒串 [1,2] [1, 2][1,2]. 一个魔咒串 S SS 的非空子串被称为魔咒串 S SS 的生成魔咒. 例如 S=[1,2,1] S = [1, 2, 1]S=[1,2,1] 时,它的生成魔咒有 [1] [1][1].[2] [2][2].[1,2] [1, 2][1,2].[2,1] [2, 1][2,1].[1,2…
题意:求字符串的可重叠的k次最长重复子串 n<=20000 a[i]<=1000000 思路:后缀数组+二分答案x,根据height分组,每组之间的height>=x 因为可以重叠,所以只要判断是否有一组的height个数>=k即可 ..]of longint; n,m,i,l,r,mid,last,k1:longint; procedure swap(var x,y:longint); var t:longint; begin t:=x; x:=y; y:=t; end; fun…
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次的子串的最长长度. 题目分析:二分枚举长度x,判断有没有最长公共前缀不小于x的并且连续出现了至少k次的有序子串区间. 代码如下: # include<iostream> # include<cstdio> # include<map> # include<vector> # include<cstring> # include<algorithm> using namespace std; # define…
[题目链接] http://poj.org/problem?id=3261 [题意] 至少出现k次的可重叠最长子串. [思路] 二分长度+划分height,然后判断是否存在一组的数目不小于k即可. 需要注意的是:用末尾添0的方法解决n==1时的RE问题,但是在can中需要忽略height[0]且考虑height[1..n]. [代码] #include<cstdio> #include<cstring> #include<iostream> #define FOR(a,…