枚举子串长度,根据height分组,如果本组sa最小值与sa最大值之差超过枚举的长度,则本组对于答案贡献为1. #include <iostream> #include <vector> #include <algorithm> #include <string> #include <string.h> #include <stdio.h> #include <queue> #include <stack> #…
Musical Theme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 25348   Accepted: 8546 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…
题目链接:http://poj.org/problem?id=3261 思路: 后缀数组的很好的一道入门题目 先利用模板求出sa数组和height数组 然后二分答案(即对于可能出现的重复长度进行二分) ,二分的时候,对 height进行分组,看是否存在一组height值使得其重复的次数大于等于k 代码如下: #include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> usin…
题意:给出一串序列,求最长的theme长度 (theme:完全重叠的子序列,如1 2 3和1 2 3  or  子序列中每个元素对应的差相等,如1 2 3和7 8 9) 要是没有差相等这个条件那就好办多了,直接裸题. 一开始想了个2B方法,后来发现真心2B啊蛤蛤蛤 to do { to length { r2[j]=r[j]+i; ) r2[i]-=; } 把新序列r2连接到原序列r的后面 process[r+r2] ..... 求for i=->88中得到的最大答案 } 正解:http://b…
SETI Time Limit: 4000/2000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description Amateur astronomers Tom and Bob try to find radio broadcasts of extraterrestrial civilizations in the air. Recentl…
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…
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…
点此看题面 大致题意: 求两个字符串中最长公共子串的长度. 关于后缀数组 关于\(Height\)数组的概念以及如何用后缀数组求\(Height\)数组详见这篇博客:后缀数组入门(二)--Height数组与LCP. 大致思路 由于后缀数组是处理一个字符串的,因此我们第一步自然是将这两个字符串拼在一起,并在中间加一个不可能出现的字符,例如\(\%\). 然后我们用后缀数组求出其\(Height\)数组. 注意一个性质,答案肯定是按字典序排名后相邻后缀的\(LCP\)值中的最大值. 因此,我们只要枚…
题意:有N(1 <= N <=20000)个音符的序列来表示一首乐曲,每个音符都是1..88范围内的整数,现在要找一个重复的主题. “主题”是整个音符序列的一个子串,它需要满足如下条件:1.长度至少为5个音符2.在乐曲中重复出现(可能经过转调,“转调”的意思是主题序列中每个音符都被加上或减去了同一个整数值.)3.重复出现的同一主题不能有公共部分. 链接:点我先转化成相邻两项的差值,然后就是找不可重叠重复子串.做法就是二分答案LEN然后根据height值进行分组 第一道后缀数组题,测了一下模板…
评测地址: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…