KMP算法
西行妖下的亡灵
这个作者很懒,什么都没留下…
展开
-
SCU4438 Censor(审查员) (KMP算法与模拟栈的应用 || HASH表与模拟栈的结合)
Censor frog is now a editor to censor so-called sensitive words (敏感词). She has a long textpp. Her job is relatively simple -- just to find the first occurence of sensitive wordwwand remove it....原创 2019-04-24 00:31:57 · 234 阅读 · 0 评论 -
CT 1459 字符串算法
A 子串查找 哈希加密函数:hash[i]=hash[i−1]∗p+idx(s[i])(idx指的是待加密字符串,p是质数) 哈希加密函数(带取余):hash[i]=(hash[i−1])∗p+idx(s[i])%mod(p和mod都是质数) 查询某段的哈希值:hash=hash[r]−hash[l−1]∗p^(r−l+1) (因为哈希加密时会多次乘p,要在区间左端点乘上相应“长度...原创 2019-08-09 00:21:56 · 95 阅读 · 0 评论 -
KMP,字典树与AC自动机,哈希算法,01字典树
KMP中的一个重要思想与AC自动机非常相似,就是失配指针。在kmp算法中指匹配失败后该返回到字符串的哪个位置,也就是俗称的特定位置的复活出生点。 KMP模板如下: //#include<pch.h> #include <iostream> #include <cstdio> #include <bits/stdc++.h> #include&l...原创 2019-08-09 23:16:42 · 151 阅读 · 0 评论