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. datatime 模块

    import datetime # 这个是一个包 里面包含 对时间的处理 对日期的处理datetime.date # 日期相关datetime.time # 时间相关 # 获取当前详细时间print( ...

  2. UVA 11990 `Dynamic'' Inversion CDQ分治, 归并排序, 树状数组, 尺取法, 三偏序统计 难度: 2

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  3. [转载] JAVA面试题和项目面试核心要点精华总结(想进大公司必看)

    JAVA面试题和项目面试核心要点精华总结(想进大公司必看) JAVA面试题和项目面试核心要点精华总结(想进大公司必看)

  4. DeepLearning4J

    http://blog.csdn.net/nysyxxg/article/details/52554734

  5. mysql数据库存储引擎及区别

    MySQL有多种存储引擎,每种存储引擎有各自的优缺点,可以择优选择使用:MyISAM.InnoDB.MERGE.MEMORY(HEAP).BDB(BerkeleyDB).EXAMPLE.FEDERAT ...

  6. Turing equation

    Turing equation 时间限制: 1 Sec 内存限制: 128 MB 题目描述 The fight goes on, whether to store numbers starting w ...

  7. 1.5 socket服务器传输文件

    socket服务器代码 # -*- coding: utf-8 -*-import sys,os,time,_thread from socket import * host = 'localhost ...

  8. SQL-39 使用索引

    题目描述 针对salaries表emp_no字段创建索引idx_emp_no,查询emp_no为10005, 使用强制索引.CREATE TABLE `salaries` (`emp_no` int( ...

  9. mysql 给表和字段加注释

    给表加注释: ALTER TABLE table_name COMMENT='这是表的注释'; 给列加注释: ALTER table table_name MODIFY `column_name` d ...

  10. gmtdefaults locate

    http://seisman.blog.ustc.edu.cn/index.php/archives/553