Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:求错误!!!!!!!!!一直WA!

Posted by proverbs at 2012-07-12 18:43:14 on Problem 2752
In Reply To:求错误!!!!!!!!!一直WA! Posted by:326775408 at 2011-03-22 18:11:59
> #include<iostream>
> #include<cmath>
> #include<string.h>
> #include<queue>
> using namespace std;
> char s[600010];
> int next[600010];
> int a[600010];
> int main()
> {//poj2752
> 	while(cin>>s+1)
> 	{
> 		int i,j;
> 		memset(a,0,sizeof(a));
> 		memset(next,0,sizeof(next));
> 		int flag=0;
> 		s[0]='0';
> 		int len=strlen(s);
> 		len=len-1;
> 		next[1]=0;
> 		for(i=2;i<=len;i++)//得到next数组
> 		{
> 			if(flag>0&&s[flag+1]!=s[i])
> 				flag=next[flag];
> 			if(s[flag+1]==s[i])
> 				flag++;
> 			next[i]=flag;//cout<<flag<<" ";
> 		}
> 		j=0;
> 		a[j++]=len;
> 		i=len;
> 		while (1)
> 		{
> 			if(next[i]<=0)
> 				break;
> 			a[j++]=next[i];
> 			i=next[i];
> 		}
> 		for(i=j-1;i>=0;i--)
> 			cout<<a[i]<<" ";
> 		cout<<endl;
> 	}
>      return 0;
>  }
len=strlen(s+1)

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator