I don't even have AC auto Jackie Now, what do I do qaq
Original question:
Jsoi to the players zyx a task, the production of a "text generator" computer software: The user of the software is some low-young people,
They are now using the GW Text Generator version V6. The software can generate a number of random articles---always generate a fixed length and completely random text
Chapter-that is, every byte in the generated article is completely random. If an article contains at least one word that the user understands,
Then we say this article is readable (we call the article A contains the word B when and only if the word b is a substring of article a). However, even following such a
Standard, the article generated by the V6 version of the GW text generator used by the user is also almost completely unreadable?. ZYX need to point out the GW text generator V6
The number of readable text in all generated text so that the V7 update can be successfully obtained. Can you help him?
N <= 60, the length of all words and text will not exceed 100
If the suffix of a string is not selectable, the string of course cannot be selected.
Extended to AC automatic Becky the node cannot be selected if the node to which the string fail points is not selectable
And then you can preprocess those nodes that can't be selected.
Then use F[I][J] to indicate the number of scenarios where the AC auto Becky goes to the J node when the text string goes to I
First, the outer enum I, then the J, if J is optional, enumerate 26 characters K,f[i][j] give J to the State (including the fail) v contribution along the K down
I can understand how to write this question, but I can't seem to extend it to a wider area. It doesn't feel good, qaq.
Code:
1#include <iostream>2#include <cstdio>3#include <algorithm>4#include <cstring>5#include <cmath>6 using namespacestd;7 Const intdalao=10007;8 intRD () {intz=0, mk=1;CharCh=GetChar ();9 while(ch<'0'|| Ch>'9'){if(ch=='-') mk=-1; Ch=GetChar ();}Ten while(ch>='0'&&ch<='9') {z= (z<<3) + (z<<1) +ch-'0'; Ch=GetChar ();} One returnz*Mk; A } - intn,m; - Chars[ the];intls; the intnxt[6100][ -],fl[6100],tt=0; - intq[6100],hd=0; - BOOLmk[6100]; - intf[ the][6100]; + voidist () { - inttmp=0; + for(intI=1; i<=ls;++i) { A if(!nxt[tmp][s[i]-'A']) nxt[tmp][s[i]-'A']=++tt; attmp=nxt[tmp][s[i]-'A']; - } -mk[tmp]=true; - } - voidGtac () { - for(intI=0;i< -; ++i)if(nxt[0][i]) q[++hd]=nxt[0][i]; in for(intk=1; k<=hd;++k) for(intI=0;i< -;++i) { - if(!nxt[q[k]][i]) nxt[q[k]][i]=Nxt[fl[q[k]]][i]; to Else{ +fl[nxt[q[k]][i]]=nxt[fl[q[k]]][i],q[++hd]=Nxt[q[k]][i]; -mk[nxt[q[k]][i]]|=Mk[nxt[fl[q[k]]][i]]; the } * } $ }Panax Notoginseng intMain () {//freopen ("ddd.in", "R", stdin); -Cin>>n>>m; the for(intI=1; i<=n;++i) scanf ("%s", s+1), Ls=strlen (s+1), ist (); + Gtac (); Af[0][0]=1; the for(intI=1; i<=m;++i) for(intj=0; j<=tt;++j)if(!mk[j] && f[i-1][j]) + for(intk=0;k< -;++k) -F[i][nxt[j][k]]= (f[i][nxt[j][k]]+f[i-1][J])%Dalao; $ intBwl=0, ans=1; $ for(intI=1; i<=m;++i) ans= (ans* -)%Dalao; - for(intI=0; i<=tt;++i)if(!mk[i]) bwl= (Bwl+f[m][i])%Dalao; -cout<< (Ans-bwl+dalao)%dalao<<Endl; the return 0; -}
View Code
"BZOJ1030" "JSOI2007" text generator