Sample Input
1
10
2 3 4 4 3 2 2 3 4 4
 
Sample Output

Case #1: 9

要求找出一段数字。

将其分成3部分,第①和第②部分成回文字串,第②和第③部分成回文字串

用manacher算出各个点的回文后字串长度,然点枚举和半径(后部分稍不注意就超时
 - -!!)

#include <cstdio>
#include <iostream>
#include <algorithm>
#define MAXN 100010
using 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>

  

2015 多校联赛 ——HDU5371(manacher + 枚举)的更多相关文章

  1. 2015 多校联赛 ——HDU5334(构造)

    Virtual Participation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Ot ...

  2. 2015 多校联赛 ——HDU5353(构造)

    Each soda has some candies in their hand. And they want to make the number of candies the same by do ...

  3. 2015 多校联赛 ——HDU5302(构造)

    Connect the Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  4. 2015 多校联赛 ——HDU5294(最短路,最小切割)

    Tricks Device Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To ...

  5. 2015 多校联赛 ——HDU5325(DFS)

    Crazy Bobo Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Tota ...

  6. 2015 多校联赛 ——HDU5316(线段树)

    Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an ...

  7. 2015 多校联赛 ——HDU5323(搜索)

    Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  8. 2015 多校联赛 ——HDU5319(模拟)

    Painter Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Su ...

  9. 2015 多校联赛 ——HDU5301(技巧)

    Your current task is to make a ground plan for a residential building located in HZXJHS. So you must ...

随机推荐

  1. 20145237 实验一 逆向与Bof基础

    20145237 实验一 逆向与Bof基础 1.直接修改程序机器指令,改变程序执行流程 此次实验是下载老师传给我们的一个名为pwn1的文件. 首先,用 objdump -d pwn1 对pwn1进行反 ...

  2. 库函数strstr的实现

    没什么说的,常规思路: 函数原型:const char* StrStr(const char *str1, const char *str2) 方法一: str1:源字符串: str2:需要查找的目的 ...

  3. pandas 数据分析使用

    https://github.com/Erick-LONG/data_analysis/blob/master/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%20%E9%8 ...

  4. hdu 4553 约会安排

    约会安排 http://acm.hdu.edu.cn/showproblem.php?pid=4553 Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  5. typescript简介

    微软作为编译器狂魔一直有一个心病,就是改良JavaScript这种语法超级烂又很多人用的编程语言,于是TypeScript诞生了 先做个对比吧:   TS JS 语法严谨性 严谨 宽松 静态性 静态 ...

  6. 新概念英语(1-19)Tired and thirsty

    新概念英语(1-19)Tired and thirsty Why do the children thank their mother? A:What's the matter, children? ...

  7. mysql(1)—— 详解一条sql语句的执行过程

    SQL是一套标准,全称结构化查询语言,是用来完成和数据库之间的通信的编程语言,SQL语言是脚本语言,直接运行在数据库上.同时,SQL语句与数据在数据库上的存储方式无关,只是不同的数据库对于同一条SQL ...

  8. 爬虫必备 User-Agent 列表

    USER_AGENTS = [ "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR ...

  9. mongodb 索引的基本命令

    mongodb的索引: 在数据量超大的时候,能够极大的增快查询速率,但是会降低更新效率.建立索引: db.集合.ensureIndex({属性:1}) //1代表升序 -1代表降序 db.集合.ens ...

  10. 【Vue中的swiper轮播组件】

    <template> <swiper :options="swiperOption" ref="mySwiper"> <!-- s ...