字典树
ITKaven
ACMER
本科软件工程专业
硕士计算机技术专业
专注于WEB开发的烟酒僧
展开
-
HDU 1251:统计难题
经典字典树题 就是输入不太友好,因为我平时不喜欢用 gets() 我一般用 scanf(“%[^\n]”,ch) 来代替 gets(ch) ,ch 是 char* 类型的,这里利用了正则表达式的性质,让 scanf() 达到了gets()的效果,也保留了 scanf() 的优点 如果有大佬可以不用gets()函数的,请留言告知,万分感谢!我的代码:#include<cstdio...原创 2018-07-23 10:03:00 · 3393 阅读 · 0 评论 -
CODEVS 4189 : 字典
经典字典树题,比较简单#include<cstdio>#include<cstring>using namespace std;const int maxn=400000+100;int trie[maxn][26],tot;inline void insert(char* ch){ int len=strlen(ch); int ...原创 2018-07-23 10:20:42 · 1165 阅读 · 0 评论 -
HDU 1671 : Phone List
字典树问题 插入每个字符串前,先判断前面某个字符串是不是该字符串的前缀,或者该字符串是不是前面某个字符串的前缀 详细请看代码:#include<cstdio>#include<cstring>using namespace std;const int maxn=100000+100;int trie[maxn][10],tot;bool vis[max...原创 2018-07-23 11:26:36 · 938 阅读 · 0 评论 -
HDU 2222 : Keywords Search
学习了字典树之后,来学一下AC自动机,其实挺简单的,但是很强大 这是一道AC自动机模板题 AC自动机学习博客:ac自动机最详细的讲解,让你一次学会ac自动机。我的代码:#include<cstdio>#include<cstring>using namespace std;const int maxn=500000+100;int trie[maxn...原创 2018-07-23 16:20:47 · 1107 阅读 · 0 评论 -
洛谷 P3808 【模板】AC自动机(简单版)
AC自动机模板题,用来检测模板正确性 代码:#include<cstdio>#include<cstring>using namespace std;const int maxn=1000000+100;int trie[maxn][26],sum[maxn],fail[maxn],tot;int que[maxn];inline void in...原创 2018-08-08 14:23:50 · 869 阅读 · 0 评论