本题有个关键点:“以上字符串中字符都是ASCII码可见字符(不包括回车)。” -----也就说AC自动机的Trie树需要128个单词分支。
#include#include #include using namespace std; const int maxw = 210 *500 + 10; const int sigma_size = 128; const int maxl = 10000 + 10; struct Trie{ int next[maxw][sigma_size],fail[maxw],end[maxw]; int root,L; int newnode(){ for(int i=0;i Q; fail[root]=root; for(int i=0;i