窝今天果断翻了SB,main函数中忘记写ac.bfs()这句话了,然后各种单步调试感觉怎么这个fail数组那么奇怪呢...很无语...后来不小心发现了果断AC,基本和上一道题类似,不过就是第几个字符串出现几次就对应的下标++,最后输出就好了。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
#define N 2000000
int ans[1234];
char s[1234][52];
char v[3000000];
struct Trie
{
int next[N][27],fail[N],mark[N];
int root,L;
int newnode()
{
memset(next[L],-1,sizeof(next[L]));
mark[L]=0;
fail[L++]=-1;
return L-1;
}
void go()
{
L=0;
root=newnode();
}
void init(char *v,int id)
{
int p=root;
for(int i=0;v[i];i++)
{
int tep=v[i]-'A&#