cychester

上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页

2018年9月25日

BZOJ 1969 航线规划 - LCT 维护边双联通分量

摘要: Solution 实际上就是查询 $u$ 到 $v$ 路径上 边双的个数 $ -1$。 并且题目仅有删边, 那么就离线倒序添边。 维护 边双 略有不同: 首先需要一个并查集, 记录 边双内的点。 在 添加边$(u,v)$时 , 若$u, v$ 已经相连, 那么把 $u, v$ 路径上的点 缩成一个点 阅读全文

posted @ 2018-09-25 13:05 cychester 阅读(248) 评论(0) 推荐(0) 编辑

2018年9月24日

UOJ 274 温暖会指引我们前进 - LCT

摘要: Solution 更新掉路径上温暖度最小的边就可以了~ Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #define ll long long 5 #define rd read() 6 using names 阅读全文

posted @ 2018-09-24 21:17 cychester 阅读(130) 评论(0) 推荐(0) 编辑

BZOJ3669 膜法森林 - LCT

摘要: Solution 非常妙的排序啊。。。 仔细想想好像确实能够找出最优解QUQ 先对第一关键字排序, 在$LCT$ 维护第二关键字的最大值 所在的边。 添边时如果$u, v$ 不连通 就直接加边。 如果连通 并且路径上的最大值 大于 当前边 的 第二关键字, 那么可以换掉。 如果 $1$ 和 $N$ 阅读全文

posted @ 2018-09-24 20:16 cychester 阅读(100) 评论(0) 推荐(0) 编辑

Luogu 4234 最小差值生成树 - LCT 维护链信息

摘要: Solution 将边从小到大排序, 添新边$(u, v)$时 若$u,v$不连通则直接添, 若连通则 把链上最小的边去掉 再添边。 若已经加入了 $N - 1$条边则更新答案。 Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algor 阅读全文

posted @ 2018-09-24 15:54 cychester 阅读(140) 评论(0) 推荐(0) 编辑

BZOJ 2594 水管局长 - LCT 维护链信息

摘要: Solution 由于链信息不好直接维护, 所以新建一个节点存储边的权值, 并把这个节点连向 它所连的节点 $u$, $v$ $pushup$中更新维护的 $mx$ 指向路径上权值最大的边的编号。 由于这题是只有删边, 没有添边, 所以可以离线倒序, 把删边变成添边。 Code 1 #include 阅读全文

posted @ 2018-09-24 07:19 cychester 阅读(211) 评论(0) 推荐(1) 编辑

2018年9月21日

Luogu 2173 [ZJOI2012]网络 - LCT

摘要: Solution $LCT$ 直接上$QuQ$ 注意$cut$ 完 需要 $d[u + c * N]--$ 再 $link$, 不然会输出Error 1的哦 Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #de 阅读全文

posted @ 2018-09-21 21:50 cychester 阅读(146) 评论(0) 推荐(0) 编辑

Luogu 2147 洞穴勘测 - LCT

摘要: Solution $LCT$ 打上 $cut$ , $link$ 和 $finroot$ 即可 Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #define rd read() 5 using namespac 阅读全文

posted @ 2018-09-21 12:29 cychester 阅读(132) 评论(0) 推荐(0) 编辑

Luogu1501 Tree II - LCT

摘要: Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #define rd read() 5 #define ll long long 6 using namespace std; 7 8 const int N = 阅读全文

posted @ 2018-09-21 11:29 cychester 阅读(89) 评论(0) 推荐(0) 编辑

BZOJ 2002 [HNOI2010]Bounce 弹飞绵羊 - LCT

摘要: Solution 只需要支持$access$ , $cut$ 和 $link$就可以了。 注意不要$makeroot$。 查询时查询 根节点的左子树大小 $+ 1$ Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 阅读全文

posted @ 2018-09-21 10:25 cychester 阅读(108) 评论(0) 推荐(0) 编辑

2018年9月20日

Luogu 3690 LCT - 模板

摘要: 推荐几篇比较好的博客: FlashHu 的 讲解比较好 : 传送门 Candy 的 代码~ : 传送门 以及神犇Angel_Kitty的 学习笔记: 传送门 Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #de 阅读全文

posted @ 2018-09-20 20:22 cychester 阅读(204) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页

导航