SCU 4438 Censor(字符串哈希)

Censor

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

She has a long text pp. Her job is relatively simple -- just to find the first occurence of sensitive word ww 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 11 string ww. The second line contains 11 string pp.

(1length of w,p51061≤length of w,p≤5⋅106w,pw,p consists of only lowercase letter)

Output

For each test, write 11 string which denotes the censored text.

Sample Input

    abc
    aaabcbc
    b
    bbb
    abc
    ab

Sample Output

    a
    

ab

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define ull unsigned long long 
const int maxn=5000005;
ull h[maxn],hash[maxn],base=123;
char t1[maxn],t2[maxn];
struct node
{
	char t;
	ull x;
}c[maxn];
int main()
{
	h[0]=1;
	for(int i=1;iL1)
				{
					if(c[tol-1].x-h[L1]*c[tol-L1-1].x==tt)
					{
						tol-=L1;
					}
				}
			}
			for(int i=1;i

你可能感兴趣的:(哈希)