- 博客(5)
- 收藏
- 关注
原创 poj 2778 AC 自动机 + 矩阵快速幂
AC自动机构建fail 指针时与 跟 原来匹配时的 AC自动机有改动。。 就是如果 这个节点k没有next[ i ] , 并不是直接跳过 ,而是 由于求转移矩阵的需要 ,顺着 k 的fail 指针 一直找到 有 next[ i ] ,然后把 k点的 next [ i ] 的指针 指向找到的那个 next[ i ] ,这样 就减少了 , 在求转移矩阵的时候, 失配时的跳转。 但这种方式 只适合
2012-12-07 22:12:24 533
原创 hdu 2222 AC自动机 。。
#include #include #include #include using namespace std; const int MAXK = 26; const int MAXN = 500010 ; const int A = 'a'; struct node { node * fail ; node * next[MAXK]; int count
2012-12-01 16:25:03 480
原创 AC 自动机 水题 hdu 3065
AC自动机 : AC自动机算法分为3步:构造一棵Trie树,构造失败指针和模式匹配过程。 在学习 AC 自动机 之前 , 一般应先学会 字典树 (也就是 tire树 ) 和 KMP 算法 (fail指针的构造 就是这个思想)。 用模拟指针实现的AC自动机 #include #include #include #include using namespace std; const
2012-12-01 16:21:20 510
原创 hdu 1251 字典树的水题
字典树的水题 #include #include #include using namespace std; struct node { int num ; node *next[26]; } ; node * root; void trie(){ int i,j; root = new node; root->num = 0; for(int i
2012-12-01 16:15:50 509
原创 hdu 1247 字典树 tire树 (简单)
找出所有的能够由其它的两个字符串组成的字符串. 可以先建起字典树,然后对每一个单词 枚举拆分。 #include #include #include using namespace std; char s[50010][50]; struct node { int num; node * next[26]; } ; node *root; void trie(){
2012-12-01 16:11:08 576
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人