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…
题目链接: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…
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…
题意:给定一个字符串,求其中一个由循环子串构成且循环次数最多的一个子串,有多个就输出最小字典序的. 析:枚举循环串的长度ll,然后如果它出现了两次,那么它一定会覆盖s[0],s[ll],s[ll*2].....这些点中相邻的两个,然后向前和向后匹配, 看看最大的匹配多大,然后把所有的答案记录下来,最后再从sa中开始枚举答案,第一个就是字典序最小的. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #includ…
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…
重复次数最多的字串,我们可以枚举循环节的长度. 然后正反两次LCP,然后发现如果长度%L有剩余的情况时,答案是在一个区间内的. 所以需要找到区间内最小的rk值. 两个后缀数组,四个ST表,$\Theta(n\log n)$ 就可以解决了 空间卡死了,瞎晶胞卡过去了. #include <map> #include <cmath> #include <queue> #include <cstdio> #include <cstring> #incl…
POJ - 3693 题意 SPOJ - REPEATS的进阶版,在这题的基础上输出字典序最小的重复字串. 思路 跟上题一样,先求出最长的重复次数,在求的过程中顺便纪录最多次数可能的长度. 因为sa数组是按照字典序排好的,所以我们顺序遍历sa数组,找到第一个符合的输出即可. PS: 通过这题大致知道了为什么之前看到有的后缀数组代码需要在字符串最后加一个0. (我的模板是OI-wiki上的,没有这一步,而且之前也没错过,可能是之前做过的题目数据没有卡到,这题只有a和b,就很大可能会出问题). 写完…
其实是论文题.. 题意:求一个字符串中,能由单位串repeat得到的子串中,单位串重复次数最多的子串.若有多个重复次数相同的,输出字典序最小的那个. 解题思路:其实跟论文差不多,我看了很久没看懂,后来总算理解了一些.假设我们的单位串长度为l,那么我们将串划分为s[0] , s[l] , s[2*l] , s[3*l]..这样,可以根据l划分为n/l段.枚举一个j,表示当前枚举的位置为s[j*l],我们要做的是,求suf[j*l]跟suf[(j+1)*l]的lcp  (这里用rmq做,询问是o(1…
题意 给出一个长度为\(n(n\leqslant 100000)\)的串,求一个字典序最小的子串使得它是某个字符串重复\(k\)次得到的,且\(k\)最大 题解 后缀数组论文上的题,跟上一篇uva那个题做法有些相似. 值得一提的是输出方案. 在用前面的位置更新答案时,如果直接跨过一段区间,那么不能统计跨过的那一段中的子串,尽管他们长度一样,但字典序可能更优. 于是有一种暴力:每次一直向前移,直到不匹配,在poj上跑出来时间跟下面的方法是差不多的. 然后一个有复杂度保证的方法:更新答案时记录一下可…