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. OOP⑷

    1.对象数组: /** *学生类 */ public class Student { // 创建一个对象数组保存3名学生的信息 Student[] stus = new Student[3]; int ...

  2. 利用awk处理学生成绩问题(难度较大)

    学生成绩表单如下: Name,Team,First Test, Second Test, Third Test Tom,Red,,, Joe,Green,,, Maria,Blue,,, Fred,B ...

  3. CSS(二)属性--文本设置

    HTML代码一 <body> <div>这是一个很黑很黑的夜晚,黑云密布,没有任何光亮透过.卖火柴的小姑娘.......</div> </body> C ...

  4. (C/C++学习笔记) 八. 程序控制语句

    八. 程序控制语句 ● 基础知识 算法的基本控制结构: 顺序结构(sequential structure), 选择结构(case structure), 循环结构(loop structure) c ...

  5. 单元测试UI

    cnpm install -g --save mocha cnpm install  -g --save chai cnpm install -g --save istanbul const {sho ...

  6. MeshLab 编译

    1.需要以下:  MeshLab 1.3.3  下载地址 http://sourceforge.net/projects/meshlab/files/meshlab Win7 X64  Visual ...

  7. python字符串转换成数字

    Action(){ int i; char *s="{str}"; i=atoi(lr_eval_string(s)); lr_output_message("%d&qu ...

  8. GTX使用(更新中)

    1.XILINX GTX介绍GTX是Virtex系列 FPGA上的低功耗吉比特收发器,在V6芯片上GTX工作带宽范围是750Mb/s到6.6Gb/s,支持收发双向,且收发双向独立.GTX接收和发送方向 ...

  9. Android开发---如何操作资源目录中的资源文件

    效果图: 1.activity_main.xml <?xml version="1.0" encoding="utf-8"?> <Linear ...

  10. CodeForces ~ 996

    Allen has a LOT of money. He has nn dollars in the bank. For security reasons, he wants to withdraw ...