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

猪胃,度娘是女人,不可轻信!!

Posted by kill_myself at 2013-05-27 22:56:05 on Problem 2406 and last updated at 2013-05-27 22:57:34
一直以来KMP我都是照抄百科的模板,一直所向披靡!
此时,我终于知道抄模板是要付出代价的!
谁知道查了一万遍原来是getnext()错了!
inline void NEXT(conststring& T,vector<int>& next)
{
//按模式串生成vector,next(T.size())
next[0]=-1;
for(int i=1;i<T.size();i++){
int j=next[i-1];
while(T[i]!=T[j+1]&& j>=0)
j=next[j] ; //递推计算
if(T[i]==T[j+1])next[i]=j+1;
else next[i]=0; //!!!!就这句坑爹
}
}
介是哪位坑爹选手的代码啊!!!
乍一看,最后一行next[i]=0;不是废话么!
最后才知道个中玄机留待众爹揣摩!
这些代码就没有啥专业人员审核么!

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