链接
题目描述
给定n个长度不超过50的由小写英文字母组成的单词用于查询,以及一篇长为m的文章,问:文中出现了多少个待查询的单词。多组数据。
样例输入
1
5
she
he
say
shr
her
yasherhs
样例输出
3
思路
AC自动机模板
裸的模板
然后YbtOJA了之后luoguWA了
luoguA了之后YbtOJ又WA了
硬生生搞了1个多小时
代码
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
char s[1000006];
int T, n, tot, ans;
int vis[1000005], ch[1000005][55], nxt[1000005], bo[1000005];
void add() {
int u = 0;
int len = strlen(s + 1);
for (int i = 1; i <= len; ++i) {