#include<stdio.h>
#include<string.h>
#define MAX 200020
char s[MAX],ss[MAX*2],str[2];
int p[MAX*2];
int chance(char s)
{
return (s- str[0] + 26) % 26 + 'a';
}
int min(int a,int b){return a>b? b:a;}
int main()
{
int i,id,mx,max,n,j,ans,m; while(scanf("%s%s",str,s)!=EOF)
{
ss[0]='$';
n=strlen(s);
for(i=0;i<n;i++)
{
ss[2*i+1]='#';
ss[2*(i+1)]=s[i];
}
ss[2*i+1]='#';
ss[2*(i+1)]='\0';
id=1;
max=0;
mx=0;
for(i=1;i<2*n+2;i++)
{
if(mx>i)
p[i]=min(p[2*id-i],mx-i);
else
p[i]=1;
while(ss[i+p[i]]==ss[i-p[i]])
{
p[i]++;
}
if(i+p[i]>mx)
{
mx=i+p[i];
id=i;
}
if(p[i]>max) {j=i; max=p[i];} }
if(max-1<2)
printf("No solution!");
else
{
if(j%2)
ans=(j/2-(max-1)/2)+1;
else
ans=j/2-(max-1)/2;
m=j/2+(max-1)/2;
printf("%d %d\n",ans-1,m-1);
for(i=ans-1;i<m;i++)
printf("%c",chance(s[i]));
printf("\n");
}
}
return 0;
}

hdu 3294 Girls&#39; research的更多相关文章

  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)

    Problem Description One day, sailormoon girls are so delighted that they intend to research about pa ...

  4. HDU 3294 Girls' research

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

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

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

  6. (回文串 Manacher )Girls' research -- hdu -- 3294

    http://acm.hdu.edu.cn/showproblem.php?pid=3294 Girls' research Time Limit:1000MS     Memory Limit:32 ...

  7. Girls' research(马拉车算法) hdu 3294

    文章目录 思路如下 Manachar代码注释 题解如下 Problem Description One day, sailormoon girls are so delighted that they ...

  8. 回文串--- Girls' research

    HDU   3294 Problem Description One day, sailormoon girls are so delighted that they intend to resear ...

  9. Manacher 算法(hdu 3068 && hdu 3294)

    今天打算补前晚 BC 的第二题,发现要用到能在 O(n) 时间求最大回文子串长度的 Manacher 算法,第一次听,于是便去百度了下,看了大半天,总算能看懂了其思想,至于他给出的代码模板我没能完全看 ...

随机推荐

  1. 使用YUM安装ZABBIX监控

    http://blog.csdn.net/aqw123456fdg/article/details/48135477 http://www.cnblogs.com/enjoycode/p/zabbix ...

  2. AJAX--XMLHttpRequest五步使使用方法

    传统浏览方式和AJAX方式的不同 多数Web应用程序都使用请求/响应模型从server上获得完整的HTML页面.经常是点击一个button,等待server对应,在点击还有一个button.然后在等待 ...

  3. iOS多线程与网络开发之多线程GCD

    郝萌主倾心贡献,尊重作者的劳动成果.请勿转载. 假设文章对您有所帮助,欢迎给作者捐赠.支持郝萌主.捐赠数额任意.重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源代码下载:点我传送 游戏官方下 ...

  4. 开源企业IM-免费企业即时通讯-ENTBOOST V0.9版本号公布

    ENTBOOST V0.9版本号公布,更新内容:1.完好多人群组聊天,提高群组聊天性能及稳定性:2.苹果IOS SDK.添加联系人管理功能,优化API和内部流程.修复部分BUG.3.添加企业应用功能集 ...

  5. Java 8 时间日期库的20个使用演示样例

    除了lambda表达式,stream以及几个小的改进之外,Java 8还引入了一套全新的时间日期API,在本篇教程中我们将通过几个简单的任务演示样例来学习怎样使用Java 8的这套API.Java对日 ...

  6. 手动新建hive编程环境(以hive-1.0.0和hive-1.2.1为例)

    如下,是用maven构建项目,本篇博文重点不是这个.初学者(小白)变成小鸟后,建议开始用maven啦! Eclipse下Maven新建项目.自动打依赖jar包(包含普通项目和Web项目) HBase ...

  7. java线程深入学习

    一.java中的线程是通过Thread类创建的, //下面是构造函数,一个共同的特点就是:都是调用init()进行创建的 public Thread() { init(null, null, &quo ...

  8. Codefroces B. Hamming Distance Sum

    Genos needs your help. He was asked to solve the following programming problem by Saitama: The lengt ...

  9. BZOJ2137: submultiple(生成函数,二项式定理)

    Description 设函数g(N)表示N的约数个数.现在给出一个数M,求出所有M的约数x的g(x)的K次方和. Input 第一行输入N,K.N表示M由前N小的素数组成.接下来N行,第i+1行有一 ...

  10. python全栈_day01

    计算机容量 1位 = 1bit  8bit = 1byte = 1字节      1024bytes = 1kbytes =1KB  1024个字符,小文档 ,几百k可以表示一张图片  1024KB ...