hiho Week 3 register

Ended

Participants:669

Verdict:Accepted
Submitted:2014-07-21 22:39:49

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 <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
#define N 10001
#define M 1000001
int next[N];
char A[M];
char B[N];
void set_next(char *B) {
    next[0] = -1;
    int m = strlen(B);
    int j = -1;
    for(int i=1; i<m; i++) {
        while(j>=0 && B[j+1] != B[i]) {
            j = next[j];
        }
        if(B[j+1] == B[i])
            j = j+1;
        next[i] = j;
    }
}
int kmp(char *A, char *B) {
    int count = 0;
    int j = -1;
    int n = strlen(A);
    int m = strlen(B);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX