同上题一样的关键点,其他没什么难度了。
#include#include #include using namespace std; const int maxw = 1000 * 50 + 10; const int sigma_size = 128; const int maxl = 2000000 + 10; char str[1010][100]; 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