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 算法,第一次听,于是便去百度了下,看了大半天,总算能看懂了其思想,至于他给出的代码模板我没能完全看 ...
随机推荐
- CF17E Palisection(回文树)
题意翻译 给定一个长度为n的小写字母串.问你有多少对相交的回文子 串(包含也算相交) . 输入格式 第一行是字符串长度n(1<=n<=2*10^6),第二行字符串 输出格式 相交的回文子串 ...
- springboot实现热部署,修改代码不用重启服务
1.引入热部署依赖 <!-- 热部署模块 --> <dependency> <groupId>org.springframework.boot</groupI ...
- string.split 应用
采用string.split将字符串依据分隔符,转换成字符串数组,生成的字符串数组中会包含空数组元素,需要通过StringSplitOptions.RemoveEmptyEntries参数选项去除. ...
- 编译bash实现history的syslog日志记录
摘要: 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://koumm.blog.51cto.com/703525/1763145 一 ...
- UVA 10515 - Powers Et Al.(数论)
UVA 10515 - Powers Et Al. 题目链接 题意:求出m^n最后一位数 思路:因为m和n都非常大,直接算肯定是不行的,非常easy想到取最后一位来算,然后又非常easy想到最后一位不 ...
- C语言:具体解释指针
指针应该算得上是c语言的精华,但也是难点. 非常多教程或者博客都有对其具体的解说与分析. 我这一节的内容,也是解说指针.但我会尽量使用图解的方式,使大家非常easy理解及掌握. 一.基本使用 先来看看 ...
- java 处理word文档 (含图片,表格内容)
因为本人长期从事Oa相关项目的开发,所以处理word文档,Pdf,Excel等是在所难免的. 1.需求 处理Excel 能够用jxl 或者poi 2需求 用户在系统上填 ...
- 如何卸载visualsvn for visual studio
新入职的公司,电脑上的visual studio已经安装了visualsvn 尝试在tools-->extensions and updates中卸载 但是uninstall按钮是被禁用掉的 谷 ...
- poj--2391--Ombrophobic Bovines(floyd+二分+最大流拆点)
Ombrophobic Bovines Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u ...
- JQ each 各种标签
类选择器: $("input[class=class1]").each(function(){ alert($(this).val()); }); ID选择器: $("i ...