题意:求目标串中出现了几个模式串。
使用一个int型的end数组记录,查询一次。
#include#include #include using namespace std; const int maxw = 50 * 10000 + 10; const int sigma_size = 26; const int maxl = 1000000 + 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