http://www.spoj.com/problems/SUBST1/en/  题目链接 SUBST1 - New Distinct Substrings no tags  Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20; Each test case consists of one string, whose le…
题目链接: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…
DISUBSTR - Distinct Substrings no tags  Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20; Each test case consists of one string, whose length is <= 1000 Output For each test case outpu…
DISUBSTR - Distinct Substrings Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20;Each test case consists of one string, whose length is <= 1000 Output For each test case output one numb…
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\)值中的最大值. 因此,我们只要枚…
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…
题意:有N(1 <= N <=20000)个音符的序列来表示一首乐曲,每个音符都是1..88范围内的整数,现在要找一个重复的主题. “主题”是整个音符序列的一个子串,它需要满足如下条件:1.长度至少为5个音符2.在乐曲中重复出现(可能经过转调,“转调”的意思是主题序列中每个音符都被加上或减去了同一个整数值.)3.重复出现的同一主题不能有公共部分. 链接:点我先转化成相邻两项的差值,然后就是找不可重叠重复子串.做法就是二分答案LEN然后根据height值进行分组 第一道后缀数组题,测了一下模板…
1297. Palindrome Time Limit: 1.0 secondMemory Limit: 16 MB The “U.S. Robots” HQ has just received a rather alarming anonymous letter. It states that the agent from the competing «Robots Unlimited» has infiltrated into “U.S. Robotics”. «U.S. Robots» s…
题目链接:http://poj.org/problem?id=2774 这是一道很好的后缀数组的入门题目 题意:给你两个字符串,然后求这两个的字符串的最长连续的公共子串 一般用后缀数组解决的两个字符串的问题都通过将一个字符串加在另一个字符串的后面来解决 我们知道对于任意一个子串都是当前字符串的某一个后缀的前缀 预处理时,假设当前输入的两个字符串为s,p;我们将p加在s的h后面 那么求这两个字符串的最长公共子串,就转化为求某两个后缀的最长公共前缀 我们知道任意两个后缀的最长公共前缀一定是heigh…