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. react 组件列表

    let data=[ [ '同时入选IMDB250和豆瓣电影250的电影', '带你进入不正常的世界', '用电[影]来祭奠逝去的岁月', '女孩们的故事[电影]', '', '使用 App [找电影 ...

  2. 面试题(校招java)

    1:linux线程和进程的区别? 进程是程序执行时的一个实例,即它是程序已经执行到课中程度的数据结构的汇集.从内核的观点看,进程的目的就是担当分配系统资源(CPU时间.内存等)的基本单位. 线程是进程 ...

  3. Day 6-3 粘包现象

    服务端: import socket import subprocess phone = socket.socket(family=socket.AF_INET, type=socket.SOCK_S ...

  4. 大白跟着“菜鸟”学node——同名事件

    若存在两个同名事件,触发事件时,两个事件监听器的回调函数会被按次序先后调用. 实例来自菜鸟教程: var events=require('events'); var emitter=new event ...

  5. NOIP2016提高组复赛C 愤怒的小鸟

    题目链接:http://uoj.ac/problem/265 题目大意: 太长了不想概括... 分析: 状压DP的模板题,把所有可能的抛物线用二进制表示,然后暴力枚举所有组合,详情见代码内注释 代码如 ...

  6. Handler主线程子线程之间的互相通信

    Handler主线程子线程之间的互相通信 package com.wyl.dansnote; import android.app.Activity; import android.os.Bundle ...

  7. php 将数组转换网址URL参数

    $array =array ( 'id' =123, 'name' = 'dopost' );echo http_build_query( $array );//得到结果id=123name=dopo ...

  8. 安装MongoDB(做成Windows服务)并加载C#驱动程序

    一 Mongodb简介: 通过查询网上的一些信息来介绍一下Mongodb的优势:MongoDB是一个面向文档的数据库,目前由10gen开发并维护,它的功能丰富,齐全,完全可以替代MySQL.在使用Mo ...

  9. AdminLTE 前端框架

    适合运维平台  后台管理系统 AdminLTE 是一个开源的后台控制面板和仪表盘 WebApp 模板. 这是一个快速的HTML模板,基于CSS框架的引导. 文档: http://adminlte.la ...

  10. 一个实际的案例介绍Spring Boot + Vue 前后端分离

    介绍 最近在工作中做个新项目,后端选用Spring Boot,前端选用Vue技术.众所周知现在开发都是前后端分离,本文就将介绍一种前后端分离方式. 常规的开发方式 采用Spring Boot 开发项目 ...