poj 2752
来源:互联网 发布:mac windows支持软件 编辑:程序博客网 时间:2024/06/04 01:32
点击打开链接#include<iostream>#include<cstdio>#include<cstring>using namespace std;const int maxn = 4*1e5;char T[maxn];int m;int d[maxn];void getNext(int next[]){ int i=0, j=next[0]=-1; //i为后缀,j为前缀 while(i<m) { if (j==-1||T[i]==T[j]) { ++i; ++j; next[i]=j; } else j=next[j]; }}int main(){ while(scanf("%s",T)!=EOF) { int next[maxn]; m=strlen(T); getNext(next); //得到next数组 int k=0; for(int i=m;next[i]!=-1;i=next[i]) d[k++]=i; printf("%d",d[k-1]); for(int i=k-2;i>=0;i--) printf(" %d",d[i]); printf("\n"); }}
阅读全文
0 0
- POJ 2752
- poj 2752
- poj 2752
- POJ 2752
- poj 2752
- POJ 2752
- poj(2752)
- POJ 2752
- poj 2752
- POJ 2752
- poj 2752
- POJ-2752
- POJ 2752
- POJ-2752
- poj 2752
- Poj 2752
- poj 2752
- POJ 2752
- PAT考试乙级1050(C语言实现) (重点题目)(按格式读取,使用容器vector)
- Git 分支
- 磁盘SMART信息概述
- ISO Latin-1字符集
- SDK接入安卓
- poj 2752
- mac php + xdebug安装 + 开机自启
- iOS 逆向 越狱手机如何安装老版本微信
- Radermacher Complexity
- 设计模式-状态模式
- [Jep]Scala与Python混编
- 欢迎使用CSDN-markdown编辑器
- tomcat启动报错java.net.MalformedURLException: Local host name unknown
- C++经典类库(C++开发必看)