摘要: 传送门 洛谷P2580的一个水题,用啥都能过,不过为了练习一下刚刚学会的字典树,还是认真做一下吧。 #include <cstdio> #include <cstring> using namespace std; #define idx(x) x - 'a' int n, m, nex; stru 阅读全文
posted @ 2017-03-29 20:05 zht467 阅读(144) 评论(1) 推荐(1) 编辑
摘要: 树状数组 支持单点修改 #include <cstdio> using namespace std; int n, m; int a[500001], c[500001]; int lowbit(int x) { return x & -x; } int sum(int x) { int ans = 阅读全文
posted @ 2017-03-29 19:19 zht467 阅读(165) 评论(0) 推荐(2) 编辑
摘要: 什么是Trie树? 形如 其中从根节点到红色节点的路径上的字母所连成的字符串即为一个Trie树上所存的字符串。 比如,这个trie树上有ab,abc,bd,dda这些字符串。 至于怎么构建和查找或添加。 简单的一批,看代码就能看懂。 不过Trie树所占的空间很大,有一些优化,暂时还没学。 1 #in 阅读全文
posted @ 2017-03-29 19:17 zht467 阅读(145) 评论(0) 推荐(1) 编辑