2015 多校联赛 ——HDU5371(manacher + 枚举)
10
2 3 4 4 3 2 2 3 4 4
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 + 枚举)的更多相关文章
- 2015 多校联赛 ——HDU5334(构造)
Virtual Participation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Ot ...
- 2015 多校联赛 ——HDU5353(构造)
Each soda has some candies in their hand. And they want to make the number of candies the same by do ...
- 2015 多校联赛 ——HDU5302(构造)
Connect the Graph Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 2015 多校联赛 ——HDU5294(最短路,最小切割)
Tricks Device Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) To ...
- 2015 多校联赛 ——HDU5325(DFS)
Crazy Bobo Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Tota ...
- 2015 多校联赛 ——HDU5316(线段树)
Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an ...
- 2015 多校联赛 ——HDU5323(搜索)
Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- 2015 多校联赛 ——HDU5319(模拟)
Painter Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Su ...
- 2015 多校联赛 ——HDU5301(技巧)
Your current task is to make a ground plan for a residential building located in HZXJHS. So you must ...
随机推荐
- Alpha冲刺Day8
Alpha冲刺Day8 一:站立式会议 今日安排: 经过为期5天的冲刺,基本完成企业人员模块的开发.因第三方机构与企业存在委托的关系.第三方人员对于风险的自查.风险列表的展示以及自查风险的统计展示(包 ...
- Python习题(第一课)
想了想其他的太简单了,还是不放了,剩三题吧. 一.完美立方 编写一个程序,对任给的正整数N (N≤100),寻找所有的四元组(a, b, c, d),使得a^3= b^3 + c^3 + d^3,其中 ...
- EasyUI 主布局整合。
博文学习地址:http://www.cnblogs.com/xishuai/p/3620327.html html: <%@ Page Language="C#" AutoE ...
- 验证码进阶(TensorFlow--基于卷积神经网络的验证码识别)
本人的第一个深度学习实战项目,参考了网络上诸多牛人的代码,在此谢过,因时间久已,不记出处,就不一一列出,罪过罪过. 我的数据集是我用脚本在网页上扒的,标签是用之前写的验证码识别方法打的.大概用了400 ...
- spring cloud之坑,访问服务时找不到报404
主要是因为: 启动时 而我访问时,api是按照下面这样访问的: 所以报404找不到
- Mybatis自动生成Xml文件,针对字段类型为text等会默认产生XXXXWithBlobs的方法问题
默认情况下产生的Mapper.xml里面存在: 需要修改generatorConfiguration.xml,里面的table加属性,如: <table domainObjectName=&qu ...
- Properties文件读写问题
项目需要在Properties配置文件中设置一些配置属性,其中包含一些中文属性.经过一上午的奋斗终于圆满解决问题. 读取Properties文件所有属性 Map<String, String&g ...
- .NET Core 2.1 Preview 2发布 - April 10, 2018
我们今天宣布发布 .NET Core 2.1 Preview 2.这也是我们在接下来的两到三个月内接近最终发布的版本,该版本现已准备好进行广泛的测试.我们希望您有任何反馈意见. ASP.NET Cor ...
- tkinter打招呼
import tkinter as tk #导入tkinter模块声明为tk class App:#创建一个类名称为App def __init__(self,master):#传入的参数顶层窗口在这 ...
- 重拾Python(4):Pandas之DataFrame对象的使用
Pandas有两大数据结构:Series和DataFrame,之前已对Series对象进行了介绍(链接),本文主要对DataFrame对象的常用用法进行总结梳理. 约定: import pandas ...