您的位置:首页 > 其它

求最长回文串长度板子

2016-08-04 22:36 148 查看
#include<cstdio>
#include<cstring>
using namespace std;
int a[10000010];
int mannchar(int *p,int n)
{
int s,e,i,max=0;
s=0;
while(s<=n)
{
i=e=s;
while(p[s]==p[e])e++;
s=e;
e--;
while(p[i]>=p[i-1]&&p[i-1]==p[e+1]) i--,e++;
int t=e-i+1;
if(max<t) max=t;
}
return max;
}
int main()
{
a[0]=9999;//*如果是字符串就 a[0] = '$'
int n,i,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%d",&a[i]);
printf("%d\n",mannchar(a,n));
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐