Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13840   Accepted: 6887 Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names t…
Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11831   Accepted: 5796 Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names t…
Seek the Name, Seek the Fame Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 12   Accepted Submission(s) : 7 Problem Description The little cat is so famous, that many couples tramp over hill an…
Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies. They seek the name, and at the same time seek the fame. In order to escape from such b…
题目链接:http://poj.org/problem?id=2752 题目大意:给你一串字符串s找到所有的公共前后缀,即既是前缀又是后缀的子串. 解题思路: 如图所示 假设字符串pi与jq为符合条件的一组公共前后缀,那么易得pi=jq,如下图所示 若在字符串pi内,pk1与k2i为公共前后缀,有因为pi=jq所以对应的k2i在字符串jq内有后缀k4q与其等价.所以pi内的公共前后缀等也是pq的公共前后缀,而i=next[q],显然是个递归. 所以,可以通过不断使pos=next[pos]进行递…
传送门 http://poj.org/problem?id=2752 题目大意:求既是前缀又是后缀的前缀的可能的长度.. 同样是KMP,和 HDU 2594 Simpsons' Hidden Talents   (   http://blog.csdn.net/murmured/article/details/12867995) 一样,只不过这题是全部输出而已. 故利用失配函数性质,一路next(好吧我的代码是f),最后倒序输出 #include<cstdio> #include<cst…
题意:给一个字符串s,问s的某个前缀与后缀相同的情况时,长度是多少. 此题使用KMP的next数组解决. next数组中,j=next[i],next[i]表示S[0...i-1]的某个后缀(字符串S[i-j,i-1])与字符串S[0...j-1]完全相同,此时的j即该段字符串的长度. 字符串s本身是最长的串,next[L]对应的S[0...next[L]]是次长的符合条件的串,其他更短的串怎么求呢. 由于字符串S[L-j...L-1]等于S[0...j-1],这样在S[0...j-1]时继续利…
给一个字符串S,求出所有前缀,使得这个前缀也正好是S的后缀.升序输出所有情况前缀的长度.KMP中的next[i]的意义就是:前面长度为i的子串的前缀和后缀的最大匹配长度.明白了next[i],那么这道题就很容易做了 #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; ; char str[maxn]; int…
题意: 要求你给出每个前后缀相同的串的长度,比如: "alala"的前缀分别为{"a", "al", "ala", "alal", "alala"}, 后缀分别为{"a", "la", "ala", "lala", "alala"}. 其中有{"a", "al…
题意:    给出一个字符串str,求出str中存在多少子串,使得这些子串既是str的前缀,又是str的后缀.从小到大依次输出这些子串的长度. 这个就是next数组的应用,next数组真是很深奥啊. 根据最后一个next数组的值,递归去找前面的值,直到是0时停止.证明见链接. 链接:http://www.cnblogs.com/dongsheng/archive/2012/08/13/2636261.html #include <map> #include <set> #inclu…