POJ 2725
#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的更多相关文章
- poj 1279 半平面交核面积
		
Art Gallery Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6668 Accepted: 2725 Descr ...
 - POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
		
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
 - POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
		
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
 - POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
		
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
 - POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
		
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
 - POJ 3254. Corn Fields 状态压缩DP (入门级)
		
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
 - POJ 2739. Sum of Consecutive Prime Numbers
		
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
 - POJ 2255. Tree Recovery
		
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
 - 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 ...
 
随机推荐
- Le Chapitre I
			
Lorsque j'avais six ans j'ai vu, une fois, une magnifique image, dans un livre sur la Forêt[fɔrε] Vi ...
 - PHP函数gmstrftime()将秒数转换成天时分秒
			
http://yangjunwei.com/a/930.html PHP函数gmstrftime()将秒数转换成天时分秒 一个应用场景需要用到倒计时的时分秒,比如新浪微博授权有效期剩余: 7天16 ...
 - 解决FileZilla Server因路径错误导致无法启动问题详细图文教程
			
问题背景 我作为一个配置无数服务器环境的人,对服务器的配置也算有所了解,不管是在linux平台还是win平台都比较熟悉,但这次帮一个朋友配置win2003服务器的时候却遇到了一个问题:前面配置IIS和 ...
 - python psutil简单示例
			
python psutil简单示例 利用psutil编写简单的检测小脚本 0.安装psutil模块 ...
 - python coroutine的学习跟总结[转]
			
简介 因为最近一段时间需要研究一些openstack相关的东西,在阅读一些相关代码的时候碰到很多python特定的一些特性,比如generator, coroutine以及一些相关的类库,比如even ...
 - (动规 或 最短路)Help Jimmy(poj 1661)
			
http://poj.org/problem?id=1661 Description "Help Jimmy" 是在下图所示的场景上完成的游戏. 场景中包括多个长度和高度各不相同的 ...
 - (求凹包)  Bicycle Race (CF 659D) 简单题
			
http://codeforces.com/contest/659/problem/D Maria participates in a bicycle race. The speedway t ...
 - Codeforces Round #535 (Div. 3) 1108C - Nice Garland
			
#include <bits/stdc++.h> using namespace std; int main() { #ifdef _DEBUG freopen("input.t ...
 - marven与Eclipse集成配置
			
maven作为一个项目构建工具,在开发的过程中很受欢迎,可以帮助管理项目中的bao依赖问题,另外它的很多功能都极大的减少了开发的难度,下面来介绍maven的安装及与eclipse的集成. maven的 ...
 - Lambda架构
			
转载:https://blog.csdn.net/brucesea/article/details/45937875 1.Lambda架构背景介绍 Lambda架构是由Storm的作者Nathan M ...