摘要:
"题面" 题解 这种题目一看就是重链剖分裸题,还是区间修改,单点查询,查询之前在遍历时要记一个$delta$,因为这一次的起点就是上一次的终点,不需要放糖,所以可以用$BIT$来写,但我写完$modify$才反应过来,所以没改了。 cpp include include include using 阅读全文
摘要:
题意 给定$n$个矩形$(x_1,y_1,x_2,y_2)$,求这$n$个矩形的面积并 题解 扫描线裸题,可以不用线段树维护,$O(n^2)$是允许的。 cpp include include include using std::sort; using std::unique; using 阅读全文
摘要:
题解 不妨采取重链剖分的方式把路径剖成区间,然后用线段树维护,考虑如何合并一个区间 由于重链剖分跳$top$时,两个端点的路径是独立的,所以不能像普通查询那样直接累加贡献,要分开处理,最后存在一个特殊情况,要将左区间的左右端点反置。(画图即可明白) 代码 cpp include include us 阅读全文
摘要:
题意 见原题 题解 重链剖分模板题 cpp include include using std::swap; typedef long long ll; const int N = 1e5 + 10; int n, m, c[N], opt, x, y; int dep[N], siz[N], fa 阅读全文
摘要:
题意 原文很清楚了 题解 重链剖分模板题,用线段树维护即可。 cpp include include include using std::max; using std::swap; const int N = 3e4 + 10, Inf = 1e9 + 7; int n, q, c[N], x, 阅读全文