博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[BZOJ1030][JSOI2007]文本生成器(AC自动机+DP)
阅读量:7078 次
发布时间:2019-06-28

本文共 589 字,大约阅读时间需要 1 分钟。

Solution

考虑算出所有不包含给定字符串的方案数,在用总数减去就行了

f[i][j]表示到第i个字符串,当前停在自动机上j点的方案数

Code

 

#include 
#include
#include
#define N 6010using namespace std;char s[110];const int mo=10007;int n,m,f[110][N],T[N][27],fail[N],tot=1,mark[N],q[N],sum=1,Ans;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}void Insert(){ scanf("%s\n",&s); int len=strlen(s),now=1; for(int i=0;i

 

转载于:https://www.cnblogs.com/void-f/p/8921708.html

你可能感兴趣的文章