首页 > 其他 > 详细

hihocoder 1032 最长回文子串

时间:2015-05-25 18:45:45      阅读:132      评论:0      收藏:0      [点我收藏+]

题目链接:

hihocoder 1032





代码:

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char str[1000105];
int fast()
{
    int start,endd,len,ans=0;
    for(int i=1;str[i];i++)
    {
        start=endd=i;
        while(str[i]==str[endd+1])
            endd++;
        i=endd;
        while(str[start-1]==str[endd+1])
            start--,endd++;
        len=endd-start+1;
        if(len>ans)
            ans=len;
    }
    return ans;
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        str[0]='!';
        scanf("%s",str+1);
        cout<<fast()<<endl;
    }
    return 0;
}


hihocoder 1032 最长回文子串

原文:http://blog.csdn.net/axuan_k/article/details/45971771

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!