C - Censor SCU - 4438

Censor

frog is now a editor to censor so-called sensitive words (敏感词).

She has a long text p. Her job is relatively simple -- just to find the first occurence of sensitive word w

and remove it.frog repeats over and over again. Help her do the tedious work.

Input

The input consists of multiple tests. For each test:

The first line contains 1string w. The second line contains 1 string p.(1≤length of w,p≤5⋅106, w,p,consists of only lowercase letter)

Output

For each test, write 1

string which denotes the censored text

Sample Input

    abc
    aaabcbc
    b
    bbb
    abc
    ab

Sample Output

    a
    
    ab
#include

using namespace std;
const int maxn=5e6+10;

char str[maxn],s[maxn];

struct node{
    char ch;
    int val;
    node(){}
    node(char _ch,int _val):ch(_ch),val(_val){}
};

node stk[maxn];
int top;
int f[maxn];
/*
模式串和文本串的比较
abc
aaabcbabccc
还是比较难受的,当时只是想到了栈这个数据结构,但是没有想到kmp,来匹配
导致匹配一直出现问题,还是做的少啊
*/
void solve(int l1,int l2){
    top=-1;
    int j=0;
    for(int i=0;ilen2){
            printf("%s\n",str);
            continue;
        }
        get_f(len1);
        solve(len1,len2);
        for(int i=0;i<=top;i++)printf("%c",stk[i].ch);
        printf("\n");
    }
    return 0;
}
#include
#define lowbit(x) (x&(-x))

#define rep(i,a,b) for(int i=a;i

 

你可能感兴趣的:(.....KMP,【ACM-数据结构】)