#include <iostream>
#include <string>
#include <algorithm>
#define MAXN 400005
using namespace std; char _m[MAXN];
int next[MAXN];
void give_next(int len);
int ans_len[MAXN];
int ans_len_index;
int ans[MAXN];
bool take_judge(int b,int len);
int main()
{
//freopen("acm.acm","r",stdin);
string s;
int i;
int j;
int len;
int index;
int cur;
//int ans;
while(getline(cin,s))
{
if(s.length() == )
{
break;
}
index = ;
//cout<<s<<endl;
//ans = 0;
//cout<<s<<endl;
for(i = ; i < s.length(); ++ i)
{
_m[i] = s[i];
}
memset(next,-,sizeof(next));
give_next(s.length()); i = s.length();
//cout<<i<<" ";
ans[index ++] = i;
for(; next[i] != ; i = next[i])
{
//cout<<next[i]<<" ";
ans[index++] = next[i];
}
for(i = index-; i >= ; -- i)
{
cout<<ans[i]<<" ";
}
cout<<ans[i]<<endl;
//cout<<endl;
// cout<<endl;
}
return ;
} bool take_judge(int b,int len)
{
int j = ;
int i;
for(i = b; i < len; ++ i,++ j)
{
if(_m[i] != _m[j])
{
break;
}
}
if(i == len)
{
return true;
}
return false;
} void give_next(int len) //此为求next 数组的方法。
{
int i;
int j;
i = ;
j = -;
next[] = -;
while(i < len)
{
if(j == - || _m[i] == _m[j])
{
i ++;
j ++;
next[i] = j;
}
else
j = next[j];
}
}

POJ 2725的更多相关文章

  1. poj 1279 半平面交核面积

    Art Gallery Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6668   Accepted: 2725 Descr ...

  2. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  3. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  4. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  5. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  6. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  7. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  8. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

  9. 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 ...

随机推荐

  1. Spring MVC和Struts2的比较[转]

    虽然说没有系统的学习过Spring MVC框架, 但是工作这么长时间, 基本上在WEB层使用的都是Spring MVC, 自己觉得Struts2也是一个不错的WEB层框架, 这两种框架至今自己还未有比 ...

  2. Win7 VS2015环境使用SDL2-2.0.4

    之前在VS中使用SDL2,如果只链接SDL2.lib,会提示 error LNK2019: unresolved external symbol _main referenced in functio ...

  3. java常用设计模式四:观察者模式

    1.定义 观察者模式定义了一种一对多的依赖关系,让多个观察者对象同时监听某一主题对象.这个主题对象在状态发生变化时,会通知所有观察者对象,使它们能够自动更新自己.观察者模式又叫发布-订阅(Publis ...

  4. mysql only_full_group_by报错的问题(转)

    原文:https://www.cnblogs.com/jim2016/p/6322703.html 在mysql 工具 搜索或者插入数据时报下面错误: ERROR 1055 (42000): Expr ...

  5. 锋利的jQuery(第二版)学习总结

    通过对<锋利的jQuery>(第二版)一书的学习,发现此书讲解通俗易懂,是学习jQuery的一本很好的指导书,特作如下总结. 此书主要讲解了jQuery的常用操作,包括认识jQuery,j ...

  6. web项目文件夹上传

    最近公司做工程项目,实现文件夹上传 网上找了很久,发现网上很多代码大都存在很多问题,不过还是让我找到了一个符合要求的项目. 对项目的文件夹上传功能做出分析,找出文件夹上传的原理,对文件夹的传输模式深入 ...

  7. 如果我写一个开源的HIS软件

    HIS也称为医院信息管理系统,如果我要写一个 开源的,会成吗?为什么要这么做?出于对这个行业的担忧及其当前该行业的一些问题的思考.我曾跟两个HIS供应商讨论过这个话题,但可以感受到他们在利益面前,最终 ...

  8. 在aliyun遇到一些问题

    1. 删除现有网站报错:“applicationhost.config 错误 无法写入配置文件” 解决办法:用管理员身份打开IIS. 2. IIS上部署MVC网站,打开后500错误:处理程序“Exte ...

  9. 利用irc服务器做物联网数据转发 c# winform程序

    利用irc协议的优点: 免费,不用购买服务器就可以实现稳定公网转发数据 开源,irc的客户端和开源库众多,省去了自己造轮子的时间 历史悠久,互联网诞生伊始就有irc 缺点:安全性比较差 简单协议接收可 ...

  10. 区间DP POJ1160村庄邮局问题

    POJ1160 题目大意:一系列村庄在一维坐标系上有序的排列,建设p个邮局,问各个村庄到邮局的最短距离和. 线性区间DP问题 dp数组的值为最短/最优距离 村庄和邮局为限制 dp[i][j]表示前i个 ...