hiho Week 3 register

Ended

Participants:669

Verdict:Accepted
Submitted:2014-07-21 14:24:36

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<stdio.h>
#include<string.h>
int next[10010];
char T[1000010],B[1000010];
void getnext()
{
    int l=strlen(B);
    int i=0,j=-1;
    next[0]=-1;
    while(i<l)
    {
        if(j==-1||B[i]==B[j])
        {
            i++;j++;
            next[i]=j;
        }
        else j=next[j];
    }
}
int KMP()
{
    getnext();
    int n=strlen(T);
    int m=strlen(B);
    int i=0,j=0,f=0;
    while(i<n)
    {
        if(j==-1 || T[i]==B[j])
        {
            i++; j++;
        }else
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX