poj 2752
来源:互联网 发布:淘宝自动回复短语大全 编辑:程序博客网 时间:2024/05/20 17:10
#include <iostream> #include <cstdio> #include <cstring> using namespace std; int Next[400005]; char str[400005]; int ans[400005]; int cnt; int len; void getNext() { Next[0] = -1; int i = 0, j = -1; while (i < len) { if (j == -1 || str[i] == str[j]) { ++i; ++j; Next[i] = j; } else j = Next[j]; } } int main() { while (scanf("%s", str) != EOF) { len = strlen(str); getNext(); cnt = 0; int t = Next[len - 1]; while (t != -1) { if (str[t] == str[len - 1]) ans[cnt++] = t + 1; t = Next[t]; } for (int i = cnt - 1; i >= 0; --i) { printf("%d ", ans[i]); } printf("%d\n", len); } return 0; }
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
- 互联网安全防御之道
- C语言学习——运算符与表达式
- 生活闲聊1
- Android核心模块及相关技术
- 高仿喵播项目
- poj 2752
- Java解析xml文件
- C(2)
- 实现简易的android 直播技术
- Java: 枚举(enumeration)和常量的区别
- 下载并编译Android内核源代码
- Eclipse保存文件时自动格式化代码
- GridView控件
- Fiddler Android真机调试