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. Python randrange() 函数

    Python randrange() 函数  Python 数字 描述 randrange() 方法返回指定递增基数集合中的一个随机数,基数缺省值为1. 语法 以下是 randrange() 方法的语 ...

  2. bzoj千题计划288:bzoj1876: [SDOI2009]SuperGCD

    http://www.lydsy.com/JudgeOnline/problem.php?id=1876 高精压位GCD 对于  GCD(a, b)  a>b 若 a 为奇数,b 为偶数,GCD ...

  3. 前端面试题之css

    1.请列出几个具有继承特性的css属性 font-family  font-size  color  line-height  text-align  text-indent 2.阐述display: ...

  4. JAVA_SE基础——47.接口

    如果一个抽象类中的所有方法都是抽象的,则可以将这个类用另一种方法来定义,即接口~ 在定义接口时,需要用interface关键字来声明,具体实例如code1 接口的定义格式:interface 接口名{ ...

  5. react-native-image-picker 运用launchCamera直接调取摄像头的缺陷及修复

    在前几天用react-native进行android版本开发当中,用到了"react-native-image-picker"的插件:根据业务的需求:点击按钮-->直接调取摄 ...

  6. Centos 6 搭建安装 Gitlab

    官方安装教程 gitlab / gitlab-ce 官网下载:https://www.gitlab.cc/downloads 官网安装说明:https://doc.gitlab.cc/ce/insta ...

  7. 《深入实践Spring Boot》阅读笔记之二:分布式应用开发

    上篇文章总结了<深入实践Spring Boot>的第一部分,这篇文章介绍第二部分:分布式应用开发,以及怎么构建一个高性能的服务平台. 主要从以下几个方面总结: Spring Boot SS ...

  8. emqtt 试用(五)emq 的用户密码认证

    MQTT 认证设置 EMQ 消息服务器认证由一系列认证插件(Plugin)提供,系统支持按用户名密码.ClientID 或匿名认证. 系统默认开启匿名认证(anonymous),通过加载认证插件可开启 ...

  9. Linux知识积累(2)dirname的使用方法

    linux中的cd "$(dirname "$0")"/是什么意思呢? 分析如下: 1.$0 表示当前动行的命令名,一般用于shell 脚本中 2.dirnam ...

  10. django的models模型 关联关系和关系查询

    模型类关系 关系字段类型 关系型数据库的关系包括三种类型: ForeignKey:一对多,将字段定义在多的一端中. ManyToManyField:多对多,将字段定义在两端中. OneToOneFie ...