hdu 3294 Girls' research
#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' research的更多相关文章
- Hdu 3294 Girls' research (manacher 最长回文串)
题目链接: Hdu 3294 Girls' research 题目描述: 给出一串字符串代表暗码,暗码字符是通过明码循环移位得到的,比如给定b,就有b == a,c == b,d == c,.... ...
- HDU 3294 Girls' research(manachar模板题)
Girls' researchTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total ...
- hdu 3294 Girls' research(manacher)
Problem Description One day, sailormoon girls are so delighted that they intend to research about pa ...
- HDU 3294 Girls' research
题目地址 manacher #include<cstdio> #include<string.h> #include<algorithm> using namesp ...
- [manacher] hdu 3294 Girls' research
题意: 给一个字符x代表真实的a 然后输出的时候转换 然后就是求最长回文子串的串是什么 长度要大于1 思路: 就是裸的manacher,弄清楚下标的转换关系就好了 代码: #include" ...
- (回文串 Manacher )Girls' research -- hdu -- 3294
http://acm.hdu.edu.cn/showproblem.php?pid=3294 Girls' research Time Limit:1000MS Memory Limit:32 ...
- Girls' research(马拉车算法) hdu 3294
文章目录 思路如下 Manachar代码注释 题解如下 Problem Description One day, sailormoon girls are so delighted that they ...
- 回文串--- Girls' research
HDU 3294 Problem Description One day, sailormoon girls are so delighted that they intend to resear ...
- Manacher 算法(hdu 3068 && hdu 3294)
今天打算补前晚 BC 的第二题,发现要用到能在 O(n) 时间求最大回文子串长度的 Manacher 算法,第一次听,于是便去百度了下,看了大半天,总算能看懂了其思想,至于他给出的代码模板我没能完全看 ...
随机推荐
- 移动端 Modal 组件开发杂谈
Vant 是有赞开发的一套基于 Vue 2.0 的 Mobile 组件库,在开发的过程中也踩了很多坑,今天我们就来聊一聊开发一个移动端 Modal 组件(在有赞该组件被称为 Popup )需要注意的一 ...
- Android——4.2.2 文件系统文件夹分析
近期公司要整android内部培训,分配给我写个培训文档.这里记录例如以下: 撰写不易,转载请注明出处:http://blog.csdn.net/jscese/article/details/4089 ...
- 微软CEO纳德拉拥抱Linux意欲何为?
"我不喜欢打一场过时的战争."微软 CEO 萨蒂亚·纳德拉说道,"我想要打一场全新的战役." 上周日晚上.萨蒂亚·纳德拉来到旧金山 North Beach 区的 ...
- Iocomp控件之数字显示【图文】
Iocomp关于数字显示有自己的一套方案.并且效果非常棒哦 效果图: 插入控件: 默认效果: 随意改动属性后: 加入变量 调用函数: ); 效果图:
- 26.angularJS $routeProvider
转自:https://www.cnblogs.com/best/tag/Angular/ O'Reilly书上的伪代码 var someModule = angular.module('someMod ...
- Spring MVC -- UEditor 编辑器整合入门
仅作为入门测试...... 下载UEditor资源 使用maven项目 <!-- 上传文件的支持 --> <dependency> <groupId>commons ...
- springMVC No mapping found for HTTP request with URI
转载自:http://blog.sina.com.cn/s/blog_534f69a00101332u.html 1.问题: No mapping found for HTTP request wit ...
- POJ Oulipo KMP 模板题
http://poj.org/problem?id=3461 Oulipo Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4 ...
- 联想 U410 超极本启用加速硬盘方法
安装步骤: 方法一: 使用raid1方法 (此方法未安装过) 方法二: 普通安装后,使用RST加速 1.改BIOS , 为AHCI启动 , 2.安装好系统后,下载RST软件并安装 3.改BIO ...
- 在Ubuntu14.04中安装Py3和切换Py2和Py3环境
前几天小编给大家分享了如何安装Ubuntu14.04系统,感兴趣的小伙伴可以戳这篇文章:手把手教你在VMware虚拟机中安装Ubuntu14.04系统.今天小编给大家分享一下在Ubuntu14.04系 ...