poj 2752 Seek the Name, Seek the Fame(kmp)
来源:互联网 发布:手机淘宝如何切换账号 编辑:程序博客网 时间:2024/05/01 07:51
求相同前后缀的位数……
代码在这:
#include <bits/stdc++.h>using namespace std;const int N=400010;char s[N];int x;int next[N],res[N];void fnext(){ int i,k; int n=strlen(s); next[0]=-1; for(i=1,k=-1;i<n;++i) { while(k!=-1&&s[i]!=s[k+1]) k=next[k]; if(s[i]==s[k+1]) k++; next[i]=k; } x=i;}int main(){ int i; while(scanf("%s",s)!=EOF) { fnext(); i=x-1; int num=0; while(i!=-1) { res[++num]=i+1; i=next[i]; } for(int i=num;i>1;i--) printf("%d ",res[i]); printf("%d\n",res[1]); } return 0;}
0 0
- poj 2752 Seek the Name, Seek the Fame(KMP)
- poj 2752 Seek the Name, Seek the Fame---kmp
- POJ 2752 Seek the Name, Seek the Fame KMP
- [poj 2752] Seek the Name, Seek the Fame[KMP]
- poj 2752 Seek the Name, Seek the Fame (KMP)
- POJ 2752 Seek the Name, Seek the Fame (KMP)
- KMP poj 2752 Seek the Name, Seek the Fame
- POJ 2752 Seek the Name, Seek the Fame KMP
- poj 2752 Seek the Name, Seek the Fame(KMP)
- POJ 2752 Seek the Name, Seek the Fame(KMP)
- POJ 2752 Seek the Name, Seek the Fame / KMP
- poj 2752 Seek the Name, Seek the Fame(KMP)
- Seek the Name, Seek the Fame - POJ 2752 KMP
- poj 2752 Seek the Name, Seek the Fame KMP
- poj 2752 Seek the Name, Seek the Fame,KMP
- poj 2752 Seek the Name, Seek the Fame(数据结构:KMP)
- POJ 2752 Seek the Name, Seek the Fame KMP题解
- POJ--2752--Seek the Name, Seek the Fame【KMP】
- gcc 内联汇编用法介绍
- 对抽象类和接口的理解
- 交叉排序
- CAFFE layers
- 图片选择方法、装置、图片处理方法和装置
- poj 2752 Seek the Name, Seek the Fame(kmp)
- Java并发编程:线程池的使用
- 十二、空白页
- H5实现win10日历效果
- 安全框架——Apache Shiro
- JavaWeb Servlet乱码处理(2)
- github环境配置
- html fixed导航条
- Knowledgeroot安装与使用入门