【POJ2752】seek the name,seek the fame
来源:互联网 发布:小米电视软件推荐 编辑:程序博客网 时间:2024/06/04 20:01
题目链接:http://poj.org/problem?id=2752
题解:
一直跳next就好
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;char s[400010]; int nxt[400010],stack[400010];void Get_nxt(char *s,int len,int nxt[]){ int j=0; nxt[1]=0; for(int i=2;i<=len;i++) { while(j&&s[i]!=s[j+1]) j=nxt[j]; j+=(s[i]==s[j+1]); nxt[i]=j; }}int main(){ while(~scanf("%s",s+1)) { int len=strlen(s+1); Get_nxt(s,len,nxt); int p=nxt[len],top=0; while(p) { stack[++top]=p; p=nxt[p]; } while(top) printf("%d ",stack[top--]); printf("%d\n",len); } return 0;}
阅读全文
0 0
- POJ2752 Seek the Name, Seek the Fame
- POJ2752:Seek the Name, Seek the Fame
- poj2752 Seek the Name, Seek the Fame
- POJ2752 Seek the Name, Seek the Fame
- poj2752 seek the name seek the fame
- poj2752 Seek the Name, Seek the Fame
- POJ2752 Seek the Name, Seek the Fame
- poj2752-Seek the Name, Seek the Fame
- poj2752 Seek the Name,Seek the Fame
- POJ2752 Seek the Name, Seek the Fame
- poj2752 seek the name,seek the fame
- POJ2752 Seek the Name, Seek the Fame
- POJ2752 Seek the Name, Seek the Fame
- poj2752 Seek the Name, Seek the Fame
- POJ2752-Seek the Name, Seek the Fame
- [POJ2752] Seek the Name,Seek the Fame
- POJ2752 Seek the Name, Seek the Fame
- 【POJ2752】seek the name,seek the fame
- 暑期集训之Bear and Three Balls
- 1064. Complete Binary Search Tree (30)
- 隐式intent
- HDU1114-基础dp&完全背包-F
- java.lang.NoClassDefFoundError: org/springframework/web/context/request/async/CallableProcessingInte
- 【POJ2752】seek the name,seek the fame
- Java学习第八天
- 关于RedisTemplate和StringRedisTemplate
- Keil综合(03)_map文件全解析
- JavaScript 常用方法总结
- 3.等待和通知(Waiting and Notification)
- java-数据类型和逻辑运算
- String的深拷贝
- 素数判定