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(int id, string s){
int len = s.length();
int now = 0

本文介绍了一道使用AC自动机解决的裸题,主要任务是计算模式串在文本串中的出现次数,并找出出现次数最多的模式串。同时,通过简单修改,可以判断模式串是否存在于文本串中。

711

被折叠的 条评论
为什么被折叠?



