随笔分类 - 数据结构——主席树
摘要:先考虑一下一个集合怎么用 $O(n)$ 时间求出来,然后用主席树推广到一个序列就可以了。大致思想就是考虑一个数的权值和它前面的数的和的关系。
阅读全文
摘要:trie 树思想运用到主席树上 "orz" cpp include include using namespace std; int n, m, a[200005], cnt, rot[200005], bb, xx, uu, vv; struct Node{ int l, r, sum; }nd[
阅读全文
摘要:树状数组不用动脑子真爽啊 cpp include include include using namespace std; typedef long long ll; int m, n, b[100005], rem, rot[100005], lson[20000005], rson[200000
阅读全文
摘要:前置技能:Count on a tree 然后带上一个启发式合并 cpp include include include using namespace std; int n, m, orz, uu, vv, ww, a[80005], b[80005], rnk[80005], rem, cnt,
阅读全文
摘要:先算出一个点前头比它大和后头比它小的数量。 每次删点就扔进一个主席树里头,防止造成重复删答案。 cpp include include include using namespace std; int n, m, a[100005], p[100005], c[100005], uu, pre[10
阅读全文
摘要:主席树放到树上而已 cpp include include include using namespace std; int n, m, lstans, uu, vv, a[100005], b[100005], rnk[100005], rem, cnt; int lson[2200005], r
阅读全文
摘要:把前缀和换成树状数组 cpp include include include using namespace std; int n, m, a[10005], b[20005], rem, cnt, sum[2100005], lson[2100005], rson[2100005], rot[10
阅读全文
摘要:关于空间,第零棵树是 $4n$,其后每棵树都要多来 $\log(n)$ 的空间,所以我是开 $n(4+\log(n))$ 的空间。 关于借用节点: 图片来自 "这里" cpp include include include using namespace std; int n, m, rot[200
阅读全文

浙公网安备 33010602011771号