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