自闭了啊,搞了一天总算把算法实现了,然而这个算法是TLE的,我的trie写法太垃圾了。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define maxn 1000005
int pstl, pstr, idc;
struct node{
node() : c(0), cnt(0), id(++idc) {
sub.clear();}
char c;
vector<node*> sub;
int id, cnt;
}*root = new node;
node *fail[maxn];
inline int fe(node *cur, char p)
{
for (int i = 0; i < cur -> sub.size(); ++i)
if (cur -> sub[i] -> c == p) return