随笔分类 - 树链剖分
摘要:https://www.luogu.com.cn/problem/P4374 洛谷这题一言难尽 添加新边影响的边只有与新边成环的所有边,那就很简单了,树链剖分树上最大值就行了。。。很简单不知道为啥是紫题 #include<iostream> #include<vector> #include<que
阅读全文
摘要:http://poj.org/problem?id=3694 q次询问,问你添加一条边后,图里还剩几个桥。 由于我热爱神仙数据结构,于是我用树链剖分过了这道题 做法: 1.并查集随便建树 2.不参与树的边加入q次询问,但不输出 3.树剖用0覆盖1,比如查询x y的路径,就把x y的路径点都覆盖成0,
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/5902/C 感谢LDK大神提供的最后解法 一个点z 到另一个点集合S的最长路为 ans 集合S中的最远点对x,y ans = max(ans,dis(x,z),dis(y,z)); 就是这样了 #include<cstring
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/4090/F 8说了,就是个树链剖分 当xy之间的距离是奇数,就考虑重新建个1010101010--这样取值的树, 当xy之间距离是偶数,直接就完整的取异或就行了,没啥难得,树链剖分板子题8 #include<iostream>
阅读全文
摘要:这题没啥可说的,就是线段树题, #include<cstring> #include<vector> #include<iostream> #include<algorithm> #include<cstdio> using namespace std; typedef long long ll;
阅读全文
摘要:这题简直树链剖分板子题。。。。真没啥可说的。当时不懂树剖,可惜啦 #include<cstring> #include<iostream> #include<algorithm> #include<queue> using namespace std; typedef long long ll; c
阅读全文
摘要:很神仙的题 https://www.luogu.com.cn/problem/P2486 大致如下图,我感觉本质还是数据结构线段树。 #include<cstring> #include<cstdio> #include<iostream> #include<algorithm> #include<
阅读全文
摘要:我感觉就是线段树+LCA的思想了 核心还是线段树 需要注意 在标记中,一个节点的所有子孙一定都是标号小于该节点的。 https://www.luogu.com.cn/problem/P2590 洛谷例题 解答 功能变多了就会很长很长 #include<cstring> #include<cstdio
阅读全文

浙公网安备 33010602011771号