传送门 后缀数组好题. 考虑枚举循环节长度lenlenlen. 然后考虑枚举循环节的起点来更新答案. 但是直接枚举每次O(n)O(n)O(n). 考虑枚举len∗k+1len*k+1len∗k+1作为起点. 然后用len∗(k−1)+1len*(k-1)+1len∗(k−1)+1和len∗k+1len*k+1len∗k+1之间的某一段有可能使循环节长度再加一. 代码: #include<iostream> #include<cstdio> #include<cstring&g…
传送门 后缀数组经典题. 貌似可以用二分答案+后缀数组? 我自己yyyyyy了一个好写一点的方法. 直接先预处理出heightheightheight数组. 然后对于所有连续的k−1k-1k−1个heightheightheight的最小值取最大值即可. 代码: #include<iostream> #include<cstdio> #include<algorithm> #define ri register int using namespace std; inli…
题意: 给出一个串,求重复次数最多的连续重复子串 分析: 比较容易理解的部分就是枚举长度为L,然后看长度为L的字符串最多连续出现几次. 既然长度为L的串重复出现,那么str[0],str[l],str[2*l]……中肯定有两个连续的出现在字符串中. 那么就枚举连续的两个,然后从这两个字符前后匹配,看最多能匹配多远. 即以str[i*l],str[i*l+l]前后匹配,这里是通过查询suffix(i*l),suffix(i*l+l)的最长公共前缀 通过rank值能找到i*l,与i*l+l的排名,我…
传送门 常数实在压不下来(蒟蒻开O(3)都过不了). 但有正确性233. 首先肯定得把两个字符串接在一起. 相当于heightheightheight数组被height<kheight<kheight<k的分成了几段,统计每段的贡献. 考虑段中每个heightheightheight作为最小值出现的次数就行了. 于是我们用单调栈求出每个位置向左右分别能延展到的最远下标然后统计答案就行了. 细节有点多. 代码: #include<iostream> #include<cs…
Maximum repetition substring Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9458   Accepted: 2915 Description The repetition number of a string is defined as the maximum number R such that the string can be partitioned into R same conse…
POJ - 3693 Maximum repetition substring 题意 输入一个串,求重复次数最多的连续重复字串,如果有次数相同的,则输出字典序最小的 Sample input ccabababc daabbccaa # Sample Output Case 1: ababab Case 2: aa #include <iostream> #include <cstdio> #include <cstring> #include <algorithm…
Maximum repetition substring Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7578   Accepted: 2281 Description The repetition number of a string is defined as the maximum number R such that the string can be partitioned into R same conse…
题目链接:https://vjudge.net/problem/POJ-3693 Maximum repetition substring Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11250   Accepted: 3465 Description The repetition number of a string is defined as the maximum number R such that the s…
重复次数最多的字串,我们可以枚举循环节的长度. 然后正反两次LCP,然后发现如果长度%L有剩余的情况时,答案是在一个区间内的. 所以需要找到区间内最小的rk值. 两个后缀数组,四个ST表,$\Theta(n\log n)$ 就可以解决了 空间卡死了,瞎晶胞卡过去了. #include <map> #include <cmath> #include <queue> #include <cstdio> #include <cstring> #incl…
Description The repetition number of a string is defined as the maximum number R such that the string can be partitioned into R same consecutive substrings. For example, the repetition number of "ababab" is 3 and "ababa" is 1. Given a…