poj2406 连续重复子串】的更多相关文章

Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 41110   Accepted: 17099 Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "…
后缀数组的论文里的例题,论文里的题解并没有看懂,,, 求一个重复次数最多的连续重复子串,又因为要找最靠前的,所以扫的时候记录最大的重复次数为$ans$,扫完后再后从头暴力扫到尾找重复次数为$ans$的第一个子串的开头,break输出就可以了 #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N = 1000…
REPEATS - Repeats no tags  A string s is called an (k,l)-repeat if s is obtained by concatenating k>=1 times some seed string t with length l>=1. For example, the string s = abaabaabaaba is a (4,3)-repeat with t = aba as its seed string. That is, th…
题意: 给出一个串,求重复次数最多的连续重复子串 分析: 比较容易理解的部分就是枚举长度为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的排名,我…
Maximum repetition substring Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8669   Accepted: 2637 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…
http://poj.org/problem?id=3693 题意:给定一个字符串,求重复次数最多的连续重复子串. 思路: 这道题确实是搞了很久,首先枚举连续子串的长度L,那么子串肯定包含了r[k],r[k+2*L],r[k+3*L].....(k是某个数)中相邻的两个.现在我们只需要枚举这相邻的两个,求出它们的最长公共前缀M,那么重复次数就是M/L+1. 由于要求的是字典序最小,最后再用sa数组从最前面的子串去找即可,符合条件的第一个即是答案. #include<iostream> #inc…
论文题例8 https://blog.csdn.net/queuelovestack/article/details/53031731这个解释很好 其实,当枚举的重复子串长度为i时,我们在枚举r[i*j]和r[i*(j+1)]的过程中,必然可以出现r[i*j]在第一个重复子串里,而r[i*(j+1)]在第二个重复子串里的这种情况,如果此时r[i*j]是第一个重复子串的首字符,这样直接用公共前缀k除以i并向下取整就可以得到最后结果.但如果r[i*j]如果不是首字符,这样算完之后结果就有可能偏小,因…
题意:给定一个串,长度<=10^5,求它重复次数最多的连续重复子串(输出字典序最小的那个). 例如ccabcabc,答案就是abcabc 一开始没想清楚,结果调了好久. 原理: 按照L划分,因为相邻两个i之间隔着一个L,s[i*L]和s[(i+1)*L]必定是真正循环节的同一个位置. 对于当前的L,i,i+1,x=s[i*L],y=s[(i+1)*L],找前找后,知道了最早能匹配到t0,最晚能匹配到t1,因为不知道当前的起始点是真正循环节的第几个点,所以我们要往前找L个点看看它们是不是真正的起始…
题目链接: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…
题目链接:https://vjudge.net/problem/SPOJ-REPEATS REPEATS - Repeats no tags  A string s is called an (k,l)-repeat if s is obtained by concatenating k>=1 times some seed string t with length l>=1. For example, the string s = abaabaabaaba is a (4,3)-repeat…