题目链接
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!

找最长回文串的长度和以及回文串所在的位置;
这一题好处理好 转换字符
比如 样例 先给的b 那么 a就是b 而z 就是 a b是c

#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;
const int MM=1e6+10;
int F[MM];
char s[2*MM];
char ma[2*MM];
int n,pos;
char t[30];
int manacher(char s[MM],int len)//这个是kuangbin的模板
{
    int l=0;
    int maxlen=-1;
    ma[l++]='S';//处理字符串
    ma[l++]='#';
    for(int i=0; i<len; i++)
    {
        ma[l++]=s[i];
        ma[l++]='#';
    }
    ma[l]=0;
    int mx=0,id=0;
    for(int i=0; i<l; i++)
    {
        F[i]=mx>i?min(F[2*id-i],mx-i):1;
        while(ma[i+F[i]]==ma[i-F[i]])
            F[i]++;
        if(i+F[i]>mx)
        {
            mx=i+F[i];
            id=i;
        }
        if(maxlen<F[i]-1)//找除最长回文串和它的中心位置pos
        {
            maxlen=F[i]-1;
            pos=i;
        }
    }
    return maxlen;
}
int main()
{
    char ch;
    t[0]='z';
    t[1]='a';
    for(int i=2; i<26; i++)
    {
        t[i]=t[i-1]+1;
    }
    while(scanf("%c %s",&ch,s)!=EOF)
    {
        getchar();
        n=strlen(s);
        int ans=manacher(s,n);//最长回文串
        int x=(pos-ans+1)/2-1;//算出回文串开始位置和结尾位置;
        int y=(ans+pos-1)/2-1;
        if(ans<=1)
        {
            printf("No solution!\n");
        }
        else
        {
            printf("%d %d\n",x,y);
            for(int i=x; i<=y; i++)
            {
                int ww=s[i]-ch;
                ww++;
                ww=ww+26;
                ww=ww%26;
                printf("%c",t[ww]);
            }
            printf("\n");
        }
    }
    return 0;
}