评测地址:https://cn.vjudge.net/problem/CSU-1632 Description 求字符串中所有出现至少2次的子串个数 Input 第一行为一整数T(T<=10)表示用例组数,每组用例占一行为一个长度不超过100000的字符串 Output 对于每组用例,输出该串中所有出现至少两次的子串个数 Sample Input 3 aabaab aaaaa AaAaA Sample Output 5 4 5 Solution Ans=sum(max(height(i)-hei…
题目链接: http://acm.hust.edu.cn/vjudge/problem/113725 Repeated Substrings Time Limit: 3000MS 样例 sample input 3 aabaab aaaaa AaAaA sample output 5 4 5 题意 求出现过两次以上的不同子串有多少种. 题解 用后缀数组求出height[]数组,然后扫一遍,发现height[i]-height[i-1]>=0;就ans+=height[i]-height[i-1]…
Milk Patterns Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 13669   Accepted: 6041 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=2774 这是一道很好的后缀数组的入门题目 题意:给你两个字符串,然后求这两个的字符串的最长连续的公共子串 一般用后缀数组解决的两个字符串的问题都通过将一个字符串加在另一个字符串的后面来解决 我们知道对于任意一个子串都是当前字符串的某一个后缀的前缀 预处理时,假设当前输入的两个字符串为s,p;我们将p加在s的h后面 那么求这两个字符串的最长公共子串,就转化为求某两个后缀的最长公共前缀 我们知道任意两个后缀的最长公共前缀一定是heigh…
Description A substring of a string T is defined as: T( i, k)= TiTi+1... Ti+k-1, 1≤ i≤ i+k-1≤| T|. Given two strings A, B and one integer K, we define S, a set of triples (i, j, k): S = {( i, j, k) | k≥ K, A( i, k)= B( j, k)}. You are to give the val…
题目链接:http://www.spoj.com/problems/DISUBSTR/ 思路: 每个子串一定是某个后缀的前缀,那么原问题等价于求所有后缀之间的不相同的前缀的个数.如果所有的后缀按照suffix(sa[1]),suffix(sa[2]),suffix(sa[3]),……suffix(sa[n])的顺序计算,不难发现,对于每一次新加进来的后缀suffix(sa[k]),它将产生n-sa[k]+1个新的前缀.但是其中有height[k]个是和前面的字符串的前缀是相同的.所以suffix…
Maximum repetition substring Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6328   Accepted: 1912 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…
Reference:IOI2009论文 http://www.cnblogs.com/ziyi--caolu/p/3192731.html #include "stdio.h" #include "string.h" #define maxn 200010 int wa[maxn],wb[maxn],wv[maxn],ws[maxn]; int rank[maxn],height[maxn]; int r[maxn],sa[maxn]; ],s2[]; int n,…
Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 19206   Accepted: 7934 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:…
Musical Theme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14874   Accepted: 5118 Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the…