【51nod】1089 最长回文子串 V2(Manacher算法)

1089 最长回文子串 V2(Manacher算法)
基准时间限制:1 秒 空间限制:131072 KB 分值: 0  难度:基础题
 收藏
 关注
回文串是指aba、abba、cccbccc、aaaa这种左右对称的字符串。
输入一个字符串Str,输出Str里最长回文子串的长度。
Input
输入Str(Str的长度 <= 100000)
Output
输出最长回文子串的长度L。
Input示例
daabaac
Output示例
5


#include
#include
char s[200010];int p[200010];
int min(int a,int b)
{
	return a i ? min(p[2 * id - i], mx - i) : 1;
	    while (s[i + p[i]] == s[i - p[i]]) 
	        p[i]++;
	    if (i + p[i] > mx) 
	    {
	        mx = i + p[i];
	        id = i;
	    }
	    max=max>p[i]?max:p[i];
	}
	return max-1;
}
int main()
{
	int l,i;
	while(scanf("%s",s)!=EOF)
		printf("%d\n",Manacher());
	return 0;
}


你可能感兴趣的:(Manacher,基础题,Manacher算法)