manacher板子
来源:互联网 发布:营改增减税数据 编辑:程序博客网 时间:2024/04/28 19:06
hdu5371
http://acm.hdu.edu.cn/showproblem.php?pid=5371
#include <cstdio>#include <iostream>#include <algorithm>#define MAXN 100010using namespace std;int n;int d[MAXN];int st[MAXN*2];int p[MAXN*2];int len;void manacher(){ int MaxId=0,id; for(int i=0; i<len; i++) { if(MaxId>i) p[i]=min(p[2*id-i],MaxId-i); else p[i]=1; while(st[i+p[i]]==st[i-p[i]]) p[i]++; if(p[i]+i>MaxId) { id=i; MaxId=p[i]+i; } }}int main(){ int T; scanf("%d",&T); for(int t=1; t<=T; t++) { scanf("%d",&n); for(int i = 0; i <= 2*n+1; i++) p[i] =0; len = 0; st[len++]= -2; st[len++]= -1; for(int i=1; i<=n; ++i) { scanf("%d",&st[len++]); st[len++] = -1; } st[len] = 0; manacher(); int maxans=1; for(int i = 3; i < len; i+=2) for(int j = maxans; j <= p[i]; j+=2) { if(p[j+i-1] >= j) maxans = j; } printf("Case #%d: %d\n",t,(maxans)/2*3); } return 0;}</span>
0 0
- manacher板子
- manacher板子
- manacher板子 洛谷P3805
- 板子
- 板子
- Manacher
- manacher
- Manacher
- Manacher
- manacher
- manacher
- manacher
- Manacher
- *Manacher
- Manacher
- 测试板子
- 板子总结
- 入手板子
- 状态压缩DP POJ3254 && POJ1185
- 如果你很累,那么你肯定哪里做错了
- IntelliJ IDEA 15.0.2运行grails工程不能自动重新加载修改后的类的问题
- ~(coop - 1) & tid
- CodeForces 597A Divisibility
- manacher板子
- 跟我一起学习MySQL技术内幕(第五版):(第三章学习日记12)
- codeblocks常用快捷键
- sp_create_table_sql2MySql 将sqlserver表结构平迁mysql
- 《分布式java应用:基础与实践》笔记3
- Unity3d PackingTag 字母大小写问题,导致图集错误
- Microservice 微服务的理论模型和现实路径
- 转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/46596109;
- 数据结构上机题目