Problem Description给出一个仅仅由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度.回文就是正反读都是一样的字符串,如aba, abba等Input输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c...y,z组成的字符串S两组case...
分类:
编程语言 时间:
2016-01-17 17:29:11
阅读次数:
120
题目大意:给出一个字符串,求其回文串的长度。有多组数据。分析:manacher算法模板题。//在原字符串两边和中间插入一个从未出现的字符,比如‘#’。然后再在最前面插入一个‘*’。#include#include#includeusing namespace std;#define MAXN 230...
分类:
其他好文 时间:
2015-12-19 12:24:50
阅读次数:
132
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-12-03 21:24:33
阅读次数:
220
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5421因为要在前面插字符,所以维护一个前缀链和后缀链,在同一棵回文树上搞,如果有某个最长回文后缀(或前缀)的长度为总长,那让前缀(或后缀)的last也赋为当前结点。#include#include#inclu...
分类:
其他好文 时间:
2015-11-24 14:37:29
阅读次数:
125
#include #include #include #include #include #include #include using namespace std;int p[210000];char s[210000];int main(){ while(~scanf("%s"...
分类:
其他好文 时间:
2015-11-20 12:12:19
阅读次数:
113
本文原创:http://www.cnblogs.com/BigBallon/p/3816890.html只为了记录学习,不为抄袭!http://www.felix021.com/blog/read.php?2040对于Manacher算法,主要的作用是用来求一个字符串的最长回文子串。这个算法的时间复...
分类:
编程语言 时间:
2015-11-16 12:35:59
阅读次数:
258
原文地址:http://www.cnblogs.com/zhxshseu/p/4947609.html%20转载请注明出处:http://www.cnblogs.com/zhxshseu/p/4947609.html问题描述:Given a string S, find the longest pa...
分类:
其他好文 时间:
2015-11-08 17:47:32
阅读次数:
244
原文:http://www.felix021.com/blog/read.php?2040首先用一个非常巧妙的方式,将所有可能的奇数/偶数长度的回文子串都转换成了奇数长度:在每个字符的两边都插入一个特殊的符号。比如 abba 变成 #a#b#b#a#, aba变成 #a#b#a#。 为了进一步减少编...
分类:
编程语言 时间:
2015-11-05 20:35:02
阅读次数:
284
1、找出一个最长的回文子串,要求中间的值最大,然后向两侧递减。2、判断条件改为:Ma[i+Mp[i]]==Ma[i-Mp[i]]&&Ma[i-Mp[i]]#include#includeusing namespace std;//求最长回文子串const int MAXN=100005;int Ma...
分类:
其他好文 时间:
2015-11-05 20:28:23
阅读次数:
283
转自:http://www.open-open.com/lib/view/open1419150233417.htmlManacher算法在介绍算法之前,首先介绍一下什么是回文串,所谓回文串,简单来说就是正着读和反着读都是一样的字符串,比如abba,noon等等,一个字符串的最长回文子串即为这个字符...
分类:
编程语言 时间:
2015-10-30 10:39:57
阅读次数:
273