HDU 3294 Girl's research(最长回文子串)
来源:互联网 发布:阿里云机顶盒刷机固件 编辑:程序博客网 时间:2024/04/30 13:22
//// main.cpp// Richard//// Created by 邵金杰 on 16/9/27.// Copyright © 2016年 邵金杰. All rights reserved.//#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=200000+100;char s[maxn*2];int p[maxn*2];int main(){ char c; while(scanf("%c %s",&c,s)!=EOF) { int len=(int)strlen(s); for(int i=len;i>=0;i--){ s[i+i+2]=s[i]; s[i+i+1]='#'; } s[0]='*'; int id=0,maxlen=0,pos=0; for(int i=2;i<2*len+1;i++) { if(p[id]+id>p[i]+i) p[i]=min(p[id*2-i],p[id]+id-i); else p[i]=1; while(s[i+p[i]]==s[i-p[i]]) p[i]++; if(p[i]+i>p[id]+id) id=i; if(maxlen<p[i]) {maxlen=p[i];pos=i;} } if(maxlen-1==1) {printf("No solution!\n");continue;} int x='a'-c; cout<<(pos-maxlen+1+1)/2-1<<" "<<(pos+maxlen-1-1)/2-1<<endl; for(int i=(pos-maxlen+1+1);i<=(pos+maxlen-1-1);i++) if(s[i]!='#') printf("%c",((s[i]+x)>='a')?(s[i]+x):(s[i]+x+26));printf("\n"); getchar(); } return 0;}
0 0
- HDU 3294 Girl's research(最长回文子串)
- HDU 3294 Girls' research【最长回文子串】
- HDU 3294Girls' research最长回文子串(暴力和manacher 两种解法)
- HDU 3294 Girls' research 【最长回文串+字符周期变换】
- hdoj 3294 Girls' research 【Manacher算法】【输出最长回文子串 + 字符转化】
- Girls' research 最长回文串
- hdu 3294 Girls' research Manacher回文串
- hdu 3068 最长回文(manacher&最长回文子串)
- hdu 3068 最长回文(最长回文子串 manacher算法)
- HDU 3068 最长回文(求最长回文子串)
- HDU 3068 最长回文 最长回文子串
- HDU 3068 最长回文子串
- hdu 3068最长回文子串
- hdu 4513 最长回文子串
- hdu 5340 最长回文子串变形
- hdu 3068 最长回文子串 manacher
- 【最长回文子串 manacher】HDU 3068
- HDU 3068 最长回文子串
- XGBoost-Python完全调参指南-参数解释篇
- Effective Java 2.0_Item 1_中英文对照
- 用于快餐行业的自动化餐厅系统构想
- QTableView,Model/View的运用(1),QAbstractTableModel
- Sicily 1001 Alphacode
- HDU 3294 Girl's research(最长回文子串)
- 数据库的关系运算
- Stock Charts(Google Code Jam 2009 Round2 C)二分图最大匹配
- 【No13】黑马安卓52期视频下载 共64.2G 视频教程下载
- 长沙培训杂记d
- Shell 脚本
- tianchai 12032 解救小哈(DFS或者BFS模版)
- 使用sklearn做单机特征工程
- duilib最新的SVN地址