Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Why AC?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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator