Problem Description
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.
 
Input
Input contains multiple cases.
Each case contains two parts, a character and a string, they are separated by one space, the character representing the real 'a' is and the length of the string will not exceed 200000.All input must be lowercase.
If the length of string is len, it is marked from 0 to len-1.
 
Output
Please execute the operation following the two steps.
If you find one, output the start position and end position of palindromic string in a line, next line output the real palindromic string, or output "No solution!".
If there are several answers available, please choose the string which first appears.
 
Sample Input
b
babd
a abcd
 
Sample Output
0 2
aza
No solution!

题意:给你一个字符表示真正的a 然后要你求解码以后的最长回文序列

思路:先manacher处理一下 然后从头到尾解码即可

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define ll long long int
using namespace std;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int moth[]={,,,,,,,,,,,,};
int dir[][]={, ,, ,-, ,,-};
int dirs[][]={, ,, ,-, ,,-, -,- ,-, ,,- ,,};
const int inf=0x3f3f3f3f;
const ll mod=1e9+;
int p[]; //注意数组的大小 要开2倍
void manacher(string s){
string temp="";
temp+="$#";
int len=s.length();
for(int i=;i<len;i++){
temp+=s[i];
temp+="#";
}
len=temp.length();
int po=; int mx=;
for(int i=;i<len;i++){
p[i]=mx>i?min(p[*po-i],mx-i):;
while(temp[p[i]+i]==temp[i-p[i]]) p[i]++;
if(i+p[i]>mx){
mx=p[i]+i;
po=i;
}
}
}
int main(){
ios::sync_with_stdio(false);
char real;
string s;
while(cin>>real>>s){
manacher(s);
int len=s.length();
int ans=;
int sp=-;
for(int i=;i<*len+;i++){
if(ans<p[i]-){
ans=p[i]-;
sp=(i-p[i])/;
}
}
if(sp==-){
cout<<"No solution!"<<endl;
}else{
cout<<sp<<" "<<sp+ans-<<endl;
for(int i=sp;i<=sp+ans-;i++)
cout<<char((s[i]-real+)%+'a');
cout<<endl;
}
}
return ;
}

hdu 3294 Girls' research(manacher)的更多相关文章

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

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

  2. HDU 3294 Girls' research(manachar模板题)

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

  3. HDU 3294 Girls' research

    题目地址 manacher #include<cstdio> #include<string.h> #include<algorithm> using namesp ...

  4. Girls' research(manacher)

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

  5. 【 HDU3294 】Girls' research (Manacher)

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

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

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

  7. [manacher] hdu 3294 Girls&#39; research

    题意: 给一个字符x代表真实的a 然后输出的时候转换 然后就是求最长回文子串的串是什么 长度要大于1 思路: 就是裸的manacher,弄清楚下标的转换关系就好了 代码: #include" ...

  8. hdu 3294 Girls&#39; research

    #include<stdio.h> #include<string.h> #define MAX 200020 char s[MAX],ss[MAX*2],str[2]; in ...

  9. hdu3294 Girls' research manacher

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

随机推荐

  1. 实验楼----PHP代码审计(sha1、md5)

    地址:http://www.shiyanbar.com/ctf/1787 题目:

  2. Python PEP8 编码规范中文版

    原文链接:https://legacy.python.org/dev/peps/pep-0008/ 参考:https://blog.csdn.net/ratsniper/article/details ...

  3. [转帖]firewall-cmd

    firewall-cmd https://wangchujiang.com/linux-command/c/firewall-cmd.html 高手大作 等哪天需要防火墙了 再练习一下. Linux上 ...

  4. js的日期操作:String转date日期格式、求日期差

    一.在js中String类型转成date格式 var date = new Date("2018-9-21 14:58:43");//就是这么简单 二.date转String类型就 ...

  5. Android——MaterialDesign之三NavigationView

    NavigationView的使用 这里我们来讲讲在Android5.0之后推出的NavigationView的具体使用方式.和普通的侧拉菜单制作方式一样,首先所有的东西还是都放在一个DrawerLa ...

  6. 如何使用 Yum Repository 安装指定版本的 MySQL

    自从从使用 debian 系的 apt-get 转到使用 yum 工具之后一直不是很习惯,也没有去看过很多工具包安装的时候到底影响到了哪些文件等.这次借这次社区版 MySQL 安装来一并梳理一下. 首 ...

  7. LODOOP中的各种边距 打印项、整体偏移、可打区域、内部边距

    Lodop中的打印项内容位置定位,除了打印项本身的top,left值,也会受其他设定或打印机的影响.打印开发,先用虚拟打印机测试出正确结果,然后客户端用打印维护微调常见问题:1.设置打印项相对于纸张居 ...

  8. Tembin

    1:组织机构和用户之间是多对一的关系,一个组织结构可以有多个成员,一个成员只能属于一个组织机构. 2:app里面的邀请成员:是邀请发送短信通知用户注册tembin账户,当用户去注册的时候下面就会显示所 ...

  9. jQuery 操作Cookie

    一个轻量级的cookie 插件,可以读取.写入.删除 cookie. 下载地址:http://plugins.jquery.com/cookie/ (在实际中可以用这个保存cookie保存用户的习惯, ...

  10. NPOI 上传Excel功能(三)

    4.验证Excel并上传 using DC.BE.Business.SAS; using DC.BE.Business.SYS; using DC.BE.Entity.SAS; using DC.BE ...