hiho Week 3 register

Ended

Participants:669

Verdict:Accepted
Submitted:2014-07-23 14:16:17

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>
char Text[1000005];
char P[10005];
int PI[10005];
int count;
void COMPUTE_PREFIX_FUNCTION()
{
    int m=strlen(P);
    PI[0]=-1;
    int k=-1;
    int q;
    for(q=2;q<=m;q++)
    {
        while(k>=0 && P[k+1]!=P[q-1])
        {
            k=PI[k];
        }
        if(P[k+1]==P[q-1])
        {
            k=k+1;
        }
        PI[q-1]=k;
    }
}
void KMP_MATCHER()
{
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX