
主席树
不拿牌不改名
ACM刚入门,博客写错了可以留言给我啊
展开
-
树上主席树+lca Count on a tree(洛谷 P2633)
Count on a tree题目描述给定一棵 n 个节点的树,每个点有一个权值。有 m 个询问,每次给你 u,v,k,你需要回答 u xor last 和 v 这两个节点间第 k 小的点权。其中 last 是上一个询问的答案,定义其初始为 0,即第一个询问的 u 是明文。输入格式第一行两个整数 n,m。第二行有 n 个整数,其中第 i 个整数表示点 i 的权值。后面 n−1 行每行两个整数 x,y,表示点 x 到点 y 有一条边。最后 m 行每行两个整数 u,v,k 表示一组询问。输出格原创 2020-05-15 23:50:24 · 683 阅读 · 0 评论 -
主席树 学习笔记
主席树主席树就是权值线段树的一个集合;模板题为求某个区间的第 K 大,权值线段树也有求第 K 大这个功能,但是不能维护区间,只能求整个全局第 K 大;所以学习这个之前,务必先搞懂权值线段树;所以代码都是这道题的;【模板】可持久化线段树 1(主席树)1、先从建树开始说起:int build(int l,int r){ int rt=++root; int d=(l+r)>&g...原创 2020-03-08 14:53:32 · 173 阅读 · 0 评论 -
[POI2014]KUR-Couriers(洛谷 P3567)
[POI2014]KUR-Couriers题目描述Byteasar works for the BAJ company, which sells computer games.The BAJ company cooperates with many courier companies that deliver the games sold by the BAJ company to its ...原创 2019-09-22 13:26:14 · 583 阅读 · 0 评论