【hdu 2222】Keywords Search】的更多相关文章

[题目链接] 点击打开链接 [算法] 此题是AC自动机模板题 AC自动机是很神奇的算法,简单点来说,就是在一棵字典树上进行KMP,它的应用范围很广,非常实用 这篇博客写得很好,推荐阅读 : http://blog.csdn.net/creatorx/article/details/71100840 [代码] 个人觉得我的代码还是写得不错的,大家可以尝试阅读一下,应该可读性较高. #include <algorithm> #include <bitset> #include <…
参考iwtwiioi的模板写出来的.上午gty讲的并没有听懂,只好自己慢慢对着模板理解. 在HDU上为什么相同的程序提交有时T有时A!!! 奉上sth神犇的模板(不是这道题): var ch:char; q,g,num:array [0..500001] of longint; st:string; son:array [0..500001,'a'..'z'] of longint; ts:array [0..1000001] of char; l,s,t,n,i,j,m,k,ans,head,…
[题目链接] https://loj.ac/problem/10057 [题意] 原题来自:HDU 2222 给定  n 个长度不超过 50 的由小写英文字母组成的单词准备查询,以及一篇长为 m 的文章,问:文中出现了多少个待查询的单词.多组数据. [题解] 模板题 [代码] #pragma GCC optimize(2) #include<queue> #include<cstdio> #include<cstring> #include<iostream>…
http://acm.hdu.edu.cn/showproblem.php?pid=2222 KMP是单模式串匹配的算法,而AC自动机是用于多模式串匹配的算法.主要由Trie和KMP的思想构成. 题意:输入N个模式串,再给出一个文本串,求文本串里出现的模式串数目. #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm>…
[HDU2222]Keywords Search Problem Description In the modern time, Search engine came into the life of everybody like Google, Baidu, etc.Wiskey also wants to bring this feature to his image retrieval system.Every image have a long description, when use…
[HDU  3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #include<cstring> using namespace std; int a[20]; __int64 dp[20][11]; void digit_dp() { memset(dp, 0LL, sizeof(dp)); dp[0][0]=1; for(int i=1; i<20; ++i)…
pid=5647">[HDU 5647]DZY Loves Connecting(树DP) DZY Loves Connecting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 332    Accepted Submission(s): 112 Problem Description DZY has an unroote…
[把三道我做过的线性基题目放在一起总结一下,代码都挺简单,主要就是贪心思想和异或的高斯消元] [然后把网上的讲解归纳一下] 1.线性基: 若干数的线性基是一组数a1,a2,a3...an,其中ax的最高位的1在第x位. [就是原集合的任意子集的异或和 与 线性基的任意子集的异或和 完全相等] 2.线性基的构造法: 对每个数p从高位到低位扫,扫到第x位为1时,若ax不存在,则ax=p并结束此数的扫描,否则令p=p xor ax. [高斯消元] 异或版高斯消元后的线性基会变成类似上面的样子(线性基是…
[HDU 2196] Computer(树的直径) 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 这题可以用树形DP解决,自然也可以用最直观的方法解,先求出树的直径,那么树的任意节点的最远点必然是直径上的两个端点之一,证明可以通过反证法构造: 设端点为a,b;设任意点为i,假设存在一点c到i的距离大鱼i到a,b的距离,那么a与c又能形成一个距离更长的点对,与ab是直径的假设不符,因此不存在c,证明完成. #include <queue> #i…
[HDU 2196] Computer 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 刘汝佳<算法竞赛入门经典>P282页留下了这个问题:给出一棵树,求每个节点的最远点,每一个节点的最远点有两种可能,一种是向下拓展的最远点,一种是父节点的最远点,那么需要两次dfs即可.一次求出每个节点的最远点和次远点,一次直接计算. #include <queue> #include <cmath> #include <cstd…