HDU4513:完美队形II(Manacher)
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)的更多相关文章
- hdu4513完美队形II manacher
吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希望从中挑出一些人,让这些人形成一个新的队形,新的队形若满足以下三点要 ...
- HDU4513 吉哥系列故事——完美队形II Manacher算法
题目链接:https://vjudge.net/problem/HDU-4513 吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others) Me ...
- hdu----(4513)吉哥系列故事——完美队形II(manacher(最长回文串算法))
吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)To ...
- HDU 4513 吉哥系列故事——完美队形II manacher
吉哥系列故事——完美队形II Problem Description 吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希 ...
- HDU 4513 吉哥系列故事――完美队形II(Manacher)
题目链接:cid=70325#problem/V">[kuangbin带你飞]专题十六 KMP & 扩展KMP & Manacher V - 吉哥系列故事――完美队形I ...
- Hdu 4513 吉哥系列故事——完美队形II (manacher变形)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4513 题目描述: 打完题目描述了,点开题目,发现题目是中文,orz.jpg.果断又删掉了,习惯真可怕 ...
- HDU4513:吉哥系列故事——完美队形II(Manacher)
吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)To ...
- 吉哥系列故事——完美队形II(hdu4513+Manacher)
吉哥系列故事--完美队形II Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) T ...
- (回文串 Manacher)吉哥系列故事——完美队形II -- hdu -- 4513
http://acm.hdu.edu.cn/showproblem.php?pid=4513 吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others) ...
随机推荐
- Hibernate中NoSession问题
今天在使用hibernate中 Note note = hibTem.load(Note.class, id); 报了一个could not initialize proxy [cn.entity.N ...
- 一:idea中使用eclipse主题快捷键
idea -->file -->import settings -->keymap-shkstart.jar 1 执行(run) alt+r 2 提示补全 (Class Name C ...
- Spring Security 安全框架
一 简介:Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架.它提供了一组可以在Spring应用上下文中配置的Bean,充分利用了Spr ...
- 高并发第六弹:线程封闭(ThreadLocal)
当访问共享的可变数据时,通常需要使用同步.一种避免使用同步的方式就是不共享数据.如果仅在单线程内访问数据,就不需要同步.这种技术被称为线程封闭. 它其实就是把对象封装到一个线程里,只有一个线程能看到这 ...
- 给model模型传数组参数
$res = $this->Company->companyDischarge($this->user_id,array(0=>'c.limit_sum>0',1=> ...
- cookie封装函数与使用方法(转)
函数封装: var Cookie = function(name, value, options) { // 如果第二个参数存在 if (typeof value != 'undefined') { ...
- python爬虫笔记----4.Selenium库(自动化库)
4.Selenium库 (自动化测试工具,支持多种浏览器,爬虫主要解决js渲染的问题) pip install selenium 基本使用 from selenium import webdriver ...
- Git『Everything up-to-date』问题解决
今天提交代码的时候遇到了一个小问题,这里解决了记下小记. 提交代码遇到『Everything up-to-date』 上网查了下,发现中文大多答非所问,少数能解决的并没有阐述原理,所以我写这篇文章记录 ...
- 鉴别JS数据类型的全套方法
ECMAScript 标准定义了 7 种数据类型:Boolean.Null.Undefined.Number.String.Symbol(ES6新增)和Object,除Object以外的那6种数据类型 ...
- is_palindrome 回文递归
# coding=utf-8def is_palindrome(n,start,end): if start>end: return 1 else: return is_palindrome(n ...