Match:Seek the Name, Seek the Fame(POJ 2752)

题目大意:给定一个字符串S,要你找到S的所有前缀后缀数组
还是Kmp的Next数组的简单应用,但是这一题有一个BUG,那就是必须输出字符串的长度(不输出就WA),然而事实上对于abcbab,这样输出会是2,6,很明显是错,但是答案还是会判对,吃惊
#include <iostream>
#include <algorithm>
#include <functional>
#include <string.h> using namespace std; static char str[];
static int _Next[], store[]; void Get_Next(const int); int main(void)
{
int Length, store_len;
while (~scanf("%s", str))
{
Length = strlen(str);
Get_Next(Length);
store_len = ; //if (_Next[Length] >= Length / 2)
// store[store_len++] = Length;
store[store_len++] = Length;
for (int k = _Next[Length]; k > ; k = _Next[k])
store[store_len++] = k;
for (int i = store_len - ; i >= ; i--)
printf("%d ", store[i]);
printf("\n");
}
return EXIT_SUCCESS;
} void Get_Next(const int Length)
{
int i = , k = -;
_Next[] = -; while (i < Length)
{
if (k == - || str[i] == str[k])
{
i++;
k++;
_Next[i] = k;
}
else k = _Next[k];
}
}

Match:Seek the Name, Seek the Fame(POJ 2752)的更多相关文章
- Seek the Name, Seek the Fame POJ - 2752
Seek the Name, Seek the Fame POJ - 2752 http://972169909-qq-com.iteye.com/blog/1071548 (kmp的next的简单应 ...
- (KMP)Seek the Name, Seek the Fame -- poj --2752
http://poj.org/problem?id=2752 Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536 ...
- Seek the Name, Seek the Fame - POJ 2752(next运用)
题目大意:小猫是非常有名气的,所以很多父母都来找它给孩子取名字,因为找的人比较多,小猫为了摆脱这个无聊的工作,于是它发明了一种取名字的办法,它把孩子父母的名字合在一起,然后从这个名字里面找一个前缀,并 ...
- Seek the Name, Seek the Fame POJ - 2752(拓展kmp || kmp)
题意: 就是求前缀和后缀相同的那个子串的长度 然后从小到大输出 解析: emm...网上都用kmp...我..用拓展kmp做的 这就是拓展kmp板题嘛... 求出extend数组后 把exten ...
- POJ 2752 Seek the Name, Seek the Fame [kmp]
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17898 Ac ...
- poj 2752 Seek the Name, Seek the Fame(KMP需转换下思想)
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10204 Ac ...
- KMP + 求相等前后缀--- POJ Seek the Name, Seek the Fame
Seek the Name, Seek the Fame Problem's Link: http://poj.org/problem?id=2752 Mean: 给你一个字符串,求这个字符串中有多少 ...
- KMP POJ 2752 Seek the Name, Seek the Fame
题目传送门 /* 题意:求出一个串的前缀与后缀相同的字串的长度 KMP:nex[]就有这样的性质,倒过来输出就行了 */ /************************************** ...
- poj 2752 Seek the Name, Seek the Fame【KMP算法分析记录】【求前后缀相同的子串的长度】
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 14106 Ac ...
随机推荐
- A simple Snippet in ST2
Reference: http://web-design-weekly.com/2012/07/03/snippets-in-sublime-text-2/ A sample - cofirm (To ...
- 了不起的Node.js读书笔记
原文摘自我的前端博客,欢迎大家来访问 http://www.hacke2.cn 第二章 Js概览 基于GoogleV8引擎 Object.keys(o) 数组方法:遍历forEach.过滤filter ...
- 密码学初级教程(五)消息认证码MAC-Message Authentication Code
密码学家工具箱中的6个重要的工具: 对称密码 公钥密码 单向散列函数 消息认证码 数字签名 伪随机数生成器 MAC能识别出篡改和伪装,也就是既可以确认消息的完整性,也可以进行认证. 消息认证码的输入包 ...
- html 框架
通过使用框架,你可以在同一个浏览器窗口中显示不止一个页面. 本例演示:如何使用三份不同的文档制作一个垂直框架. <html> <frameset cols="25%,50% ...
- USB协议[转]_基本上涵盖了所有最基础的USB协议相关知识。
背景: 需要使用到USB协议,我一直尝试着去强记这个流程,现在看来,其实不用.看多了,把这个过程具象出来,就牢牢记住了. 正文: 正文转自:http://fangjian0518.blog.163.c ...
- SRM 513 2 1000CutTheNumbers(状态压缩)
SRM 513 2 1000CutTheNumbers Problem Statement Manao has a board filled with digits represented as St ...
- 【知乎网】Linux IO 多路复用 是什么意思?
提问一: Linux IO多路复用有 epoll, poll, select,知道epoll性能比其他几者要好.也在网上查了一下这几者的区别,表示没有弄明白. IO多路复用是什么意思,在实际的应用中是 ...
- linux 驱动 工作队列
http://blog.sina.com.cn/s/blog_78d30f6b0102uyaf.html http://blog.csdn.net/lyc_stronger/article/detai ...
- div动态显示iframe内容
在div里隐藏不了iframe <div id="popupmenu" style="position:relative; display:none; z-inde ...
- hiberante入门
Hibernate 目前企业级应用一般均采用面向对象的开发方法,而内存中的对象数据不能永久存在,如想借用关系数据库来永久保存这些数据的话,无疑就存在一个对象-关系的映射过程.在这种情形下,诞生了许多解 ...