hdu3068 最长回文串 (manacher)
来源:互联网 发布:淘宝身份证怎么解绑 编辑:程序博客网 时间:2024/04/30 02:44
题目点我点我点我
题目大意:中文题不解释
解题思路:马拉车裸模版题
/* ***********************************************┆ ┏┓ ┏┓ ┆┆┏┛┻━━━┛┻┓ ┆┆┃ ┃ ┆┆┃ ━ ┃ ┆┆┃ ┳┛ ┗┳ ┃ ┆┆┃ ┃ ┆┆┃ ┻ ┃ ┆┆┗━┓ 马 ┏━┛ ┆┆ ┃ 勒 ┃ ┆ ┆ ┃ 戈 ┗━━━┓ ┆┆ ┃ 壁 ┣┓┆┆ ┃ 的草泥马 ┏┛┆┆ ┗┓┓┏━┳┓┏┛ ┆┆ ┃┫┫ ┃┫┫ ┆┆ ┗┻┛ ┗┻┛ ┆************************************************ */#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>using namespace std;#define rep(i,a,b) for (int i=(a),_ed=(b);i<=_ed;i++)#define per(i,a,b) for (int i=(b),_ed=(a);i>=_ed;i--)const int inf_int = 2e9;const long long inf_ll = 2e18;#define inf_add 0x3f3f3f3f#define mod 1000000007#define LL long long#define ULL unsigned long long#define MS0(X) memset((X), 0, sizeof((X)))#define Sd(X) int (X); scanf("%d", &X)#define Sdd(X, Y) int X, Y; scanf("%d%d", &X, &Y)#define Sddd(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)const int maxn = 3e5;char s[maxn],str[maxn];int len1,len2,p[maxn],ans;void init(){ str[0] = '$'; str[1] = '#'; for(int i=0;i<len1;i++) { str[i*2+2] = s[i]; str[i*2+3] = '#'; } len2 = len1*2 + 2; str[len2] = '*';}void manacher(){ int id=0,mx=0; for(int i=0;i<len2;i++) { if(mx>i)p[i] = min(p[id*2-i],mx-i); else p[i] = 1; for(;str[i-p[i]]==str[i+p[i]];p[i]++); if(p[i]+i>mx) { mx = p[i] + i; id = i; } }}int main(){//freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout);ios::sync_with_stdio(0);cin.tie(0);while(~scanf("%s",s)) { len1 = strlen(s); init(); manacher(); ans = 0; for(int i=0;i<len2;i++)ans = max(ans,p[i]); cout<<ans-1<<endl; } return 0;}
0 0
- hdu3068 最长回文串 (manacher)
- hdu3068(最长回文manacher)
- Manacher(hdu3068最长回文)
- hdu3068 最长回文(manacher)
- HDU3068 最长回文(manacher)
- 【HDU3068】最长回文【manacher】
- HDU3068 最长回文 manacher
- 【HDU3068】最长回文【Manacher】
- 最长回文 hdu3068 manacher
- Manacher HDU3068 最长回文
- HDU3068[最长回文]--Manacher
- manacher算法求最长回文子串(hdu3068)
- HDU3068(最长回文子串manacher算法)
- HDU3068-manacher算法-最长回文串
- hdu3068 最长回文(manacher 算法)
- hdu3068最长回文(manacher算法)
- HDU3068 最长回文(Manacher算法)
- HDU3068 最长回文(Manacher算法)
- js- 常用脚本代码
- TYVJ 1051 选课
- 网站盈利
- Minimum Path Sum
- asdsa
- hdu3068 最长回文串 (manacher)
- html入门学习
- iOS中使用第三方键盘UIKeyboardWillShowNotification执行多次
- 二级指针相关
- C++迭代器
- Sublime强大功能介绍
- OpenCV中threshold自动阈值,类似matlab中的graythresh
- 测试执行前环境检查
- 数据结构(二叉树)