![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
AC自动机
Rancho__
这个作者很懒,什么都没留下…
展开
-
POJ 1204 Word Puzzles(AC自动机)
这题的数据卡在,如下:5 5 3ABCDEFGHIJKLMNOPQRSTUVWXYPQRRSRSTpuzzle中间的行中可以包含要查询的多个单词。这个问题很好解决,SearchDfa的时候别return就行了,一直搜到字符串的结尾。但是这样做也有一个bug,如果数据是这样的:4 7 5ABCDEFGHIJKLMNOPQRSTUVWXYZAKRSTUSTUT...原创 2019-08-21 11:23:02 · 144 阅读 · 0 评论 -
POJ 3987 Computer Virus on Planet Pandora (AC自动机优化)
题意问一个字符串中包含多少种模式串,该字符串的反向串包含也算。思路解析一下字符串,简单。建自动机的时候,做路径压缩,跑优化版的ac自动机,跑过的模式串不能二次计数。代码附赠一大波样例#include <iostream>#include <stdio.h>#include <queue>#include <string.h>...原创 2019-08-22 11:47:51 · 278 阅读 · 0 评论 -
洛谷 P3808 【模板】AC自动机(简单版) (AC自动机优化板子)
题中有一个坑点,就是模式串可以相同,并且全部计数。#include <bits/stdc++.h>using namespace std;const int maxn=1e6+10;const int N=maxn;char str[maxn];struct Dfa { int trie[N][26],cnt; int e[N]; int fail[N]; ch...原创 2019-08-22 12:07:53 · 108 阅读 · 0 评论