
AC自动机
拔光祖国小草
存放一下做的题。
展开
-
AC自动机
AC自动机是基于KMP思想和字典树的一种数据结构,是用来处理多模式匹配的。至于详细的解释百度很多博客有。我就记录一下模板void build_ac_automation(node *root){ head = tail = 0;//应该是这样吧 int i; root->fail = NULL; q[head++] = root; while原创 2017-08-17 21:05:34 · 211 阅读 · 0 评论 -
AC自动机模板
struct Aho{ struct node{ int next[26]; int fail,cnt; }state[maxn]; queue<int> q; int size; int idx(char ch) {return ch - 'a';} void init(){ while(...原创 2018-03-15 16:12:39 · 141 阅读 · 0 评论 -
Uva11468(AC自动机+概率dp)
坑死我了,其实我还是不太懂为什么一定要补上不存在的边? 但是这题的妙处就是可以由fail跑出所有的后缀来#include <iostream>#include <algorithm>#include <queue>#include <stack>#include <cstdio>#include <string>...原创 2018-03-15 21:17:23 · 286 阅读 · 0 评论