(字符串的模式匹配4.7.19——前缀数组suffix的应用)POJ 2752 Seek the Name, Seek the Fame(求解一个字符串中前缀和后缀一样的位置)
来源:互联网 发布:添加网络打印机步骤 编辑:程序博客网 时间:2024/06/15 13:39
/* * poj_2752.cpp * * Created on: 2013年10月29日 * Author: Administrator */#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int maxn = 400005;int main() {char str[maxn];while (scanf("%s", str) != EOF) {int len = strlen(str);int suffix[maxn + 1];int ans[maxn+1];//应用KMP算法计算单词w的前缀函数suffix[0] = -1;suffix[1] = 0;int cur, p = 0;for (cur = 2; cur <= len; ++cur) {while (p >= 0 && str[p] != str[cur - 1]) {p = suffix[p];}suffix[cur] = ++p;}//求解前缀和后缀一样的位置..int i,j = 0;for(i = len ; suffix[i] != -1;){//只要suffix[i]!=-1都是前缀和后缀一样的ans[j++] = i;i = suffix[i];}for(i = j - 1 ; i > 0 ; --i){printf("%d ",ans[i]);}printf("%d\n",ans[0]);}return 0;}
- (字符串的模式匹配4.7.19——前缀数组suffix的应用)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
- POJ-2752 Seek the Name, Seek the Fame(kmp中next数组的应用)
- POJ2752 Seek the Name, Seek the Fame 【既是前缀又是后缀的子串】
- POJ - 2752 - Seek the Name, Seek the Fame (KMP-打印前缀后缀长度)
- Seek the Name, Seek the Fame next数组的应用
- poj--2752Seek the Name, Seek the Fame KMPnext数组的应用
- POJ 2752 Seek the Name, Seek the Fame(KMP,next数组的应用)
- Seek the Name, Seek the Fame POJ 2752【KMP next数组的应用】
- POJ 2752 Seek the Name, Seek the Fame(next数组的应用)
- POJ 2752: Seek the Name, Seek the Fame(简单KMP-NEXT数组的应用)
- POJ 2752 Seek the Name, Seek the Fame(KMP next数组的应用)
- poj 2752 Seek the Name, Seek the Fame 【在原串中 找所有既是原串前缀又是原串后缀的子串长度】
- 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(next数组的理解)
- POJ 2752 Seek the Name, Seek the Fame(KMP的next数组)
- 备份数据库
- Mahout源码分析DistributedLanczosSolver(3)--Job2
- 编译时向内核添加新设备 模块的方式动态的将驱动加入内核,但这种方式加入的驱动程序,当系统重新启动时, 还需要重新用模块的方式进行插入,如果是系统内常用的设备驱动采用这种方式进行加载, 就会很不方便。
- 如何在Visual Studio项目中正确添加汇编代码
- ios开发有用的文档
- (字符串的模式匹配4.7.19——前缀数组suffix的应用)POJ 2752 Seek the Name, Seek the Fame(求解一个字符串中前缀和后缀一样的位置)
- YARN/MRv2 Resource Manager深入剖析—用户交互相关模块分析
- 依赖倒置原则
- [Usaco 2011 Dec]Umbrellas for Cows
- 一步一步在Linux上安装Oracle 11gR2 RAC (5)
- JavaScript实现浮点数转十六进制
- Netbeans 七和Subversion(svn) 1.7
- 60个开发者不容错过的免费资源库JQuery
- 回溯法 ----- 递归的一种实现