One day, sailormoon girls are so delighted that they intend to research about palindromic strings. Operation contains two steps:
First step: girls will write a long string (only contains lower case) on the paper. For example, "abcde", but 'a' inside is not the real 'a', that means if we define the 'b' is the real 'a', then we can infer that 'c' is the real 'b', 'd' is the real 'c' ……, 'a' is the real 'z'. According to this, string "abcde" changes to "bcdef".
Second step: girls will find out the longest palindromic string in the given string, the length of palindromic string must be equal or more than 2.

题意:有一个字符串,先将它进行循环映射,再求其中最长的回文子串,长度至少大于等于2

manacher裸题

 #include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std; const int maxn=2e5+;
char s[maxn],t[maxn<<];
char res[maxn];
int p[maxn<<]; void manacher(){
int len=strlen(s),l=;
t[l++]='$';
t[l++]='#';
for(int i=;i<len;++i){
t[l++]=s[i];
t[l++]='#';
}
t[l]=;
int maxx=,num=;
for(int i=;i<l;++i){
p[i]=maxx>i?min(p[*num-i],maxx-i):;
while(t[i+p[i]]==t[i-p[i]])p[i]++;
if(i+p[i]>maxx){
maxx=i+p[i];
num=i;
}
}
} int main(){
char c[];
while(scanf("%s%s",c,s)!=EOF){
int l=strlen(s);
for(int i=;i<l;++i){
s[i]='a'+(s[i]-c[]+)%;
}
manacher();
int pos=,ans=;
for(int i=;i<*l+;++i){
if(p[i]->ans){
pos=i;ans=p[i]-;
}
}
int ans1=0x3f3f3f3f,ans2=,cnt=;
for(int i=pos-p[pos]+;i<=pos+p[pos]-;++i){
if(t[i]!='#'){
res[cnt++]=t[i];
if(i<ans1)ans1=i;
if(i>ans2)ans2=i;
}
}
res[cnt]=;
if(p[pos]->){
printf("%d %d\n",(ans1-)/,(ans2-)/);
printf("%s\n",res);
}
else printf("No solution!\n");
}
return ;
}

hdu3294 Girls' research manacher的更多相关文章

  1. HDU3294 Girls' research —— Manacher算法 输出解

    题目链接:https://vjudge.net/problem/HDU-3294 Girls' research Time Limit: 3000/1000 MS (Java/Others)    M ...

  2. Girls' research(manacher)

    Girls' research Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) ...

  3. Hdu 3294 Girls' research (manacher 最长回文串)

    题目链接: Hdu 3294  Girls' research 题目描述: 给出一串字符串代表暗码,暗码字符是通过明码循环移位得到的,比如给定b,就有b == a,c == b,d == c,.... ...

  4. 【 HDU3294 】Girls' research (Manacher)

    BUPT2017 wintertraining(15) #5F HDU - 3294 题意 给定字母x,字符串变换一下: 'x'-1 -> 'z', 'x'->'a', 'x'+1-> ...

  5. hdu 3294 Girls' research(manacher)

    Problem Description One day, sailormoon girls are so delighted that they intend to research about pa ...

  6. kuangbin专题十六 KMP&&扩展KMP HDU3294 Girls' research

    One day, sailormoon girls are so delighted that they intend to research about palindromic strings. O ...

  7. HDU3294 Girls' research

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...

  8. HDU----(3294)Girls' research(manacher)

    Girls' research Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)T ...

  9. (回文串 Manacher )Girls' research -- hdu -- 3294

    http://acm.hdu.edu.cn/showproblem.php?pid=3294 Girls' research Time Limit:1000MS     Memory Limit:32 ...

随机推荐

  1. 延时显示(类QQ头像显示)

    <!doctype html> <html> <head> <meta charset="utf-8"> <meta name ...

  2. 一款c语言实现的赛车游戏

    博主学习c语言已经有一段时间了,出于对自己学习检验的目的,自制了一款c语言赛车游戏. 由于本质是检验和尝试,所以并没有注重游戏的界面.下文是开发文档,在博主的github网页可以下载源码,注意本项目使 ...

  3. day04流程控制之while循环

    流程控制之while循环 1.什么是while循环 循环指的是一个重复做某件事的过程 2.为何有循环 为了让计算机能像人一样重复 做某件事 3.如何用循环 ''' # while循环的语法:while ...

  4. ActiveMQ的P2P示例

    ActiveMQ的P2P示例(点对点通信) (1)下载安装activemq,启动activeMQ. 详细步骤参考博客:http://www.cnblogs.com/DFX339/p/9050878.h ...

  5. (C/C++学习笔记) 十九. 模板

    十九. 模板 ● 模板的基本概念 模板(template) 函数模板:可以用来创建一个通用功能的函数,以支持多种不同形参,进一步简化重载函数的函数体设计. 语法: template <<模 ...

  6. spring boot 集成 quartz 定时任务

    spring boot: @EnableScheduling开启计划任务支持,@Scheduled计划任务声明 1.pom.xml 引入依赖 <dependency> <groupI ...

  7. Java集合(续)

    java学习笔记 --- 集合 1.定义:集合是一种容器,专门用来存储对象 数组和集合的区别?   A:长度区别  数组的长度固定    集合长度可变         B:内容不同  数组存储的是同一 ...

  8. Java实验2

    1.给定一组字符,编程输出里面数值最大者. package experiment; import java.util.Arrays; public class ShenYue { public sta ...

  9. kettle在linux下执行任务

    1.下载 最新版下载 7.1 https://community.hitachivantara.com/docs/DOC-1009855 准备 上传任务文件 .kjb,.ktr 上传mysql 驱动 ...

  10. elk之elasticsearch安装

    环境: centos7 jdk8 参考: https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.htmlhttp:// ...