题目链接:http://poj.org/problem?id=2774 这是一道很好的后缀数组的入门题目 题意:给你两个字符串,然后求这两个的字符串的最长连续的公共子串 一般用后缀数组解决的两个字符串的问题都通过将一个字符串加在另一个字符串的后面来解决 我们知道对于任意一个子串都是当前字符串的某一个后缀的前缀 预处理时,假设当前输入的两个字符串为s,p;我们将p加在s的h后面 那么求这两个字符串的最长公共子串,就转化为求某两个后缀的最长公共前缀 我们知道任意两个后缀的最长公共前缀一定是heigh…
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:…
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,…
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…
hdu题目 poj题目 参考了 罗穗骞的论文<后缀数组——处理字符串的有力工具> 题意:求两个序列的最长公共子串 思路:后缀数组经典题目之一(模版题) //后缀数组sa:将s的n个后缀从小到大排序后将 排序后的后缀的开头位置 顺次放入sa中,则sa[i]储存的是排第i大的后缀的开头位置.简单的记忆就是“排第几的是谁”. //名次数组rank:rank[i]保存的是suffix(i){后缀}在所有后缀中从小到大排列的名次.则 若 sa[i]=j,则 rank[j]=i.简单的记忆就是“你排第几”…
Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 23696   Accepted: 9705 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:…
Language: Default Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 21228   Accepted: 8708 Case Time Limit: 1000MS Description The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes…
题目大意:求两个字符串的最长公共子串长度 把两个串接在一起,中间放一个#,然后求出height 接下来还是老套路,二分出一个答案ans,然后去验证,如果有连续几个位置的h[i]>=ans,且存在sa[i]的最大值在第二个串里,最小值在第一个串里,说明答案成立 别再把后缀数组敲错了 #include <cmath> #include <cstdio> #include <cstring> #include <algorithm> #define ll l…
题意:给出两个字符串,求最长公共子串的长度. 题解:首先将两个字符串连在一起,并在中间加一个特殊字符(字串中不存在的)切割,然后两个串的最长公共字串就变成了全部后缀的最长公共前缀.这时就要用到height数组,由于随意两个后缀的公共前缀必然是某些height值中的最小值,而这个值假设最大则一定是height中的最大值.在此题中还要注意height最大一定要在两个值所代表的后缀分属不同的字符串地前提下. #include<cstdio> #include<cstring> #incl…
Long Long Message   Description The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days: his mother is getting ill. Being worried about spending so much on railway tickets (Byterland is such a bi…