Description

Input

Output

Sample Input

 

Sample Output

 

Solution

才发现我之前不会证$Manacher$复杂度……QAQ

题意是求最长向心非递减回文串。在$Manacher$函数向两边扩展的时候特判一下就好了。

┑( ̄Д  ̄)┍复杂度是对的啊……因为$Manacher$的时间复杂度证明和向两边扩的次数有关。

Code

 #include<iostream>
#include<cstring>
#include<cstdio>
#define N (200009)
using namespace std; int T,n,x,tot,s[N],len[N]; void Manacher()
{
int x,ans=,mid=,maxn=;
for (int i=; i<=tot; ++i)
{
if (i>maxn) x=;
else x=min(maxn-i+,len[mid*-i]);
while (s[i-x]==s[i+x] && s[i-x]<=s[i-x+]) ++x;
len[i]=x;
if (i+x->maxn) maxn=i+x-, mid=i;
ans=max(ans,x-);
}
printf("%d\n",ans);
} int main()
{
scanf("%d",&T);
while (T--)
{
scanf("%d",&n);
tot=; s[++tot]=1e9; s[++tot]=-;
for (int i=; i<=n; ++i)
scanf("%d",&x), s[++tot]=x, s[++tot]=-;
s[++tot]=1e9;
Manacher();
}
}

HDU4513:完美队形II(Manacher)的更多相关文章

  1. hdu4513完美队形II manacher

    吉哥又想出了一个新的完美队形游戏!  假设有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希望从中挑出一些人,让这些人形成一个新的队形,新的队形若满足以下三点要 ...

  2. HDU4513 吉哥系列故事——完美队形II Manacher算法

    题目链接:https://vjudge.net/problem/HDU-4513 吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others)    Me ...

  3. hdu----(4513)吉哥系列故事——完美队形II(manacher(最长回文串算法))

    吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)To ...

  4. HDU 4513 吉哥系列故事——完美队形II manacher

    吉哥系列故事——完美队形II Problem Description 吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希 ...

  5. HDU 4513 吉哥系列故事――完美队形II(Manacher)

    题目链接:cid=70325#problem/V">[kuangbin带你飞]专题十六 KMP & 扩展KMP & Manacher V - 吉哥系列故事――完美队形I ...

  6. Hdu 4513 吉哥系列故事——完美队形II (manacher变形)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4513 题目描述: 打完题目描述了,点开题目,发现题目是中文,orz.jpg.果断又删掉了,习惯真可怕 ...

  7. HDU4513:吉哥系列故事——完美队形II(Manacher)

    吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)To ...

  8. 吉哥系列故事——完美队形II(hdu4513+Manacher)

    吉哥系列故事--完美队形II Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) T ...

  9. (回文串 Manacher)吉哥系列故事——完美队形II -- hdu -- 4513

    http://acm.hdu.edu.cn/showproblem.php?pid=4513 吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others) ...

随机推荐

  1. mysql 修改初始化密码【转】

    转:http://www.jb51.net/article/39454.htm 方法1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password fo ...

  2. 思维导图(JavaScript基础)——温习一下下

  3. android chrome iframe设置src属性无法启动app

    0x01 Android Intents with Chrome Android有一个很少人知道的特性可以通过web页面发送intent来启动apps.以前通过网页启动app是通过设置iframe的s ...

  4. 使用 Vuejs 开发 chrome 插件的注意事项

    使用 Vuejs 开发 chrome 插件 chrome 插件的开发其实并不难,web开发者可以使用 html, css, javascript 轻松的开发实用的 chrome 插件. 一个好的 ch ...

  5. CSS 画一个八卦

    效果图: 实现原理: 设置高度为宽度的2倍的一个框,利用 border 补全另一半的宽度,设置圆角 用两个 div 设置不同的颜色,定位到圆的上下指定位置. 最后只剩下里面的小圆圈了.设个宽高,圆角即 ...

  6. 例如android:layout_marginBottom的值为负数

    为什么有时候像android:layout_marginBottom等变量的赋值为负数? 例如如下代码: <?xml version="1.0" encoding=" ...

  7. ew代理实战

    前言 渗透内网代理必不可少,本文做个记录 正文 工具下载地址 http://rootkiter.com/EarthWorm/ ssocksd开启 socks5 代理 环境 代理:192.168.211 ...

  8. CSS 小结笔记之定位

    定位也是Css中一个非常强大的属性.定位主要是用来移动盒子,将其移动到我们想要的位置. 定位分为两部分 1.边偏移 left | right |top |bottom:偏移大小:(边偏移一般制定上就不 ...

  9. The directory '/home/stone/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If execu

    使用sudo pip install ......的时候出现下面一段黄色的代码: The directory '/home/stone/.cache/pip/http' or its parent d ...

  10. 团队项目个人进展——Day03

    一.昨天工作总结 冲刺第三天,昨天忙着整理数据结构相关知识,在团队项目上只是花了少部分时间来对地图的样式布局进行调整 二.遇到的问题 无 三.今日工作规划 继续昨天的规划,研究地图定位代码,并通过编写 ...