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

Why AC?

Posted by dooder_daodao at 2011-07-31 19:36:38 on Problem 3461
void GetNext(char *t,int lt)
{
	int i,j;
	nxt[0]=-1;
	for(i=0,j=-1;i<lt;i++){
		while(j!=-1&&t[i]!=t[j])
			j=nxt[j];
		nxt[i+1]=++j;
	}
}
int KMP(char *s,int ls,char *t,int lt)
{
	int i,j,r=0;
	for(i=j=0;i<ls;i++){
		while(j!=-1&&s[i]!=t[j])
			j=nxt[j];
		j++;
		if(j==lt) r++;
	}
	return r;
}

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