
【数据结构】LinkCutTree
文章平均质量分 87
cz_xuyixuan
这个作者很懒,什么都没留下…
展开
-
【BZOJ2049】【SDOI2008】洞穴勘测
【题目链接】点击打开链接【思路要点】LinkCutTree模板题,支持维护动态森林的联通性,通过询问所在子树的根部来实现。时间复杂度\(O(MLogN)\)。【代码】#includeusing namespace std;#define MAXN 10005struct LinkCutTree { struct Node原创 2018-01-16 08:57:23 · 270 阅读 · 0 评论 -
【BZOJ2594】【WC2006】水管局长数据加强版
【题目链接】点击打开链接【思路要点】若题目仅包含询问操作,显然我们只需保留一棵图的最小生成树,在树上询问两点间边权的最大值即可。而本题中多了一种删边操作,但没有强制在线,因此,我们可以将操作离线,转化为加边操作。用LinkCutTree维护动态最小生成树即可。时间复杂度\(O((M+Q)LogN)\)。【代码】#include<bits/stdc++.h>using namespac...原创 2018-01-17 20:26:23 · 271 阅读 · 0 评论 -
【BZOJ3669】【UOJ3】【NOI2014】魔法森林
【题目链接】BZOJUOJ【思路要点】对边的权值\(A\)排序,依次加入图中,用LinkCutTree维护权值\(B\)的最小生成树。时间复杂度\(O(MLogN)\)。【代码】#include<bits/stdc++.h>using namespace std; #define MAXN 50005#define MAXM 100005#define INF 1e9stru...原创 2018-02-28 18:26:04 · 242 阅读 · 0 评论 -
【BZOJ3282】Tree
【题目链接】点击打开链接【思路要点】LinkCutTree模板题。时间复杂度\(O(MLogN)\)。【代码】#include<bits/stdc++.h>using namespace std;const int MAXN = 3e5 + 5;template <typename T> void read(T &x) { int f = 1; x = 0;...原创 2018-03-16 09:07:43 · 785 阅读 · 0 评论 -
【BZOJ2002】【HNOI2010】Bounce 弹飞绵羊
【题目链接】点击打开链接【思路要点】补档博客,无题解。【代码】#include<bits/stdc++.h>using namespace std;#define MAXN 200005int n;struct LinkCutTree { struct Node { bool rev; int father, child[2], size, up; }; Node...原创 2018-03-14 13:48:29 · 285 阅读 · 0 评论 -
【BZOJ1180】【CROATIAN2009】OTOCI
【题目链接】点击打开链接【思路要点】动态树模板题。时间复杂度\(O(QLogN)\)。【代码】#include<bits/stdc++.h>using namespace std;#define MAXN 30005template <typename T> void read(T &x) { x = 0; int f = 1; char c = getc...原创 2018-05-21 10:37:00 · 172 阅读 · 0 评论 -
【BZOJ2555】SubString
【题目链接】点击打开链接【思路要点】补档博客,无题解。【代码】#include<bits/stdc++.h>using namespace std;#define MAXN 1200005#define MAXM 3000005template <typename T> void read(T &x) { x = 0; int f = 1; char c...原创 2018-05-21 11:24:48 · 224 阅读 · 0 评论 -
【BZOJ4530】【BJOI2014】大融合
【题目链接】 点击打开链接 【思路要点】 用LinkCutTree维护这棵树,在轻边的父亲处记录子树信息即可。 时间复杂度O(QLogN)O(QLogN)O(QLogN)。 【代码】 #include<bits/stdc++.h>using namespace std;const int MAXN = 100005;...原创 2018-07-03 20:28:38 · 248 阅读 · 0 评论 -
【省内训练2019-07-01】Ring
【思路要点】对于一个边集的右端点 iii ,应当存在阈值 lftilft_ilfti ,满足左端点在 lftilft_ilfti 左侧时答案为 YesYesYes ,否则答案为 NoNoNo ,且不难发现 lftilft_ilfti 是单调的。使用类似 TwoPointersTwoPointersTwoPointers 的思想用 LCTLCTLCT 计算 lftlftlft 数组即可...原创 2019-07-01 13:25:39 · 246 阅读 · 0 评论