Seek the Name, Seek the Fame
2015-08-07 20:19
267 查看
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 14103 | Accepted: 7016 |
ababcababababcabab aaaaaSample Output
2 4 9 18 1 2 3 4 5
该题的题意是这样的,给若干个字符串,判断该字符串前n个字符和后n个字符是否相同,相同并按按从小到大的顺序输出n。
如果还有点困惑可以看一下这个链接有大神做的解题报告点击打开链接
#include<stdio.h>#include<string.h>char a[401000];int p[401000];int c[400100];int len;void kmp(){int i,j;i=0;j=-1;p[0]=-1;while(i<len){if(j==-1||a[i]==a[j]){i++;j++;p[i]=j;}else j=p[j];}}int main(){while(scanf("%s",a)!=EOF){len=strlen(a);kmp();int i,j,k=0;for(i=len;p[i]!=-1;i=p[i])c[k++]=i;printf("%d ",c[k-1]);for(j=k-2;j>=0;j--)printf("%d ",c[j]);printf("\n");}}[/code]
相关文章推荐
- HDUOJ 又一版A+B 题目1877
- poj 2195 Going Home【最小费用最大流】
- hdu4124
- 模态框
- 数据库锁
- IO学习
- IO学习
- bzoj1485
- 2015学校的书面总结招募书面采访蓝汛通信算法
- 双指针
- 杭电 2087 剪花布条 kmp水题
- 图文介绍windows下实现编译ffmpeg工程的详细步骤
- 【MyBatis】MyBatis Tomcat JNDI原理及源码分析
- Manacher HDOJ 3068 最长回文
- c++/c中流的概念
- HDOJ Zipper (DFS)
- java 深入解析FileInputStream和FileOutputStream
- style-visibility
- 【mybatis】mybatis数据源源码剖析(JNDI、POOLED、UNPOOLED)
- ORA-00600: [kcratr1_lastbwr] 报错处理办法