AC自动机的裸题,
求模式串在文本串中出现的次数。并输出出现次数最多的字符串。
还有的就是求模式串有没有在文本串中出现过。
只要改一下 询问中for循环就行。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#define mem(x,v) memset(x,v,sizeof(x))
#define go(i,a,b) for (int i = a; i <= b; i++)
#define og(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long LL;
const double EPS = 1e-10;
const int INF = 0x3f3f3f3f;
const int N = 2e4+10;
struct Tree{
int fail;
int vis[27];
int num;
string t;
}Ac[N];
struct node{
string s;
int id;
bool operator <(const node &a)const{
return id < a.id;
}
}p[200];
int ans,cnt,cur[N],tt,tot;
bool vis[N];
void Clean(int x){
mem(Ac[x].vis,0);
Ac[x].fail = 0;
Ac[x].num = 0;
cur[x] = 0;
}
void Build(