想总结的太多了。。。白天再来吧
#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long #define ull unsigned long long #define pb push_back #define FOR(a) for(int i=1;i<=a;i++) const int inf=0x3f3f3f3f; const int maxn=2e6+71; const long long mod=998244353; const int sigma=27; int cnt[maxn]; struct automata{ int ch[maxn][sigma]; int val[maxn]; //是第几个串 int f[maxn]; int len[maxn]; //字典树深度 int sz; int idx(char x){return x-'a';} int newnode(){ memset(ch[sz],0,sizeof(ch[sz])); f[sz]=val[sz]=0; return sz++; } void init(){ memset(val,0,sizeof val); sz=0; newnode(); } int insert(char *s,int v){ int u=0; int _len=strlen(s); for(int i=0;i<_len;i++){ int id=s[i]-'a';//s[i]-'a'; //cout<q; q.push(0); while(!q.empty()){ int u=q.front();q.pop(); for(int i=0;i