贴瓷砖(AC_AUTOMAN)

本文介绍了AC_AUTOMAN算法在解决字符串匹配问题中的应用。该算法允许匹配字符串相互重叠,并能计算出无法匹配的字符数量。在实现过程中,作者提到了void root最好设为0以方便操作,并详细阐述了fail指针的建立过程,包括关键的广度优先搜索(BFS)部分,这是AC_AUTOMAN的核心所在。
摘要由CSDN通过智能技术生成

A string S of N chars is given
We were asked to use m strings to match . Each string can be used serval times .strings for matching can intersect with each other .
The question is to find out how many chars of S can’t be matched .

The solution is AC_AUTOMAN .
this is the first time I type this algorithm .

#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std ;

#define N 300010
#define M 5100

char s[N] , z[M] ;

int i , j , k , n , m , T ;

int q[4000010] ;

struct AC_Automan {
    AC_Automan() {
        Len = -1 ;
    }
    int s[27] , nx , Len , de ;
    bool En ;
}g[4000010] ;

int tag[N] ;

int main() { 
    scanf(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值