
Trie/可持久化Trie
Exception2017
OI总结
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
hdu1251 Trie字典树模板
原题:http://acm.hdu.edu.cn/showproblem.php?pid=1251 题解:Trie 字典树模板,没什么好说的,本篇用的是数组写法。 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N=1000010; ...原创 2019-02-04 20:42:38 · 200 阅读 · 1 评论 -
poj3630 Trie字典树
原题:http://poj.org/problem?id=3630 题解:将所有数字建成字典树,当插入时无新节点生成,经过别的有标记的节点时,就是前缀。 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> using namespace std; c...原创 2019-02-09 22:03:09 · 127 阅读 · 0 评论 -
P4735 最大异或和 01可持久化Trie树模板
原题:https://www.luogu.org/problemnew/show/P4735 题解:观察一下式子,将a数组求一个异或前缀和,其实就是s[n]^x^s[p-1]的最大值 p∈[l,r],就是区间对一个数的异或的最最大值。假设我们把这个区间放进Trie字典树中,对于一个x的询问,可以用贪心的思想,反着走找到最大值。但是确定出给定区间的Trie树,用类似于主席树的思想,建一颗动态开点的...原创 2019-04-28 22:37:16 · 269 阅读 · 0 评论 -
[TJOI2018]异或 树链剖分+可持久化Trie树
原题:https://www.luogu.org/problemnew/show/P4592 题解:很明显如果是一个序列的话要用到Trie。树上操作时可以用树链剖分转化为序列形式,然后建Trie树就行了。其实就是两个版子。 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; struct E{int t...原创 2019-04-29 00:01:22 · 169 阅读 · 0 评论