![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
lca
蜗角虚名羊
这个作者很懒,什么都没留下…
展开
-
bzoj4719: [Noip2016]天天爱跑步
题目 题解#include<bits/stdc++.h>using namespace std;const int N=300003,M=600003;struct kk{ int u,v,lca,dis;}p[N];struct node{ int to,ne;}e[M];int b[N+M],cnt[M],ans[N],w[N],dis[N]...原创 2018-05-17 16:40:59 · 177 阅读 · 2 评论 -
强联通/lca tarjan
强联通: hdu3861 The King’s Problem#include&amp;amp;lt;cstdio&amp;amp;gt;#include&amp;amp;lt;cstring&amp;amp;gt;#include&amp;amp;lt;queue&amp;amp;gt;using namespace std;const int N=50003,M=100003,inf=1e8原创 2018-05-17 22:29:08 · 179 阅读 · 0 评论 -
bzoj4326: NOIP2015 运输计划
题目题解:大佬的博客 思路其实很简单,就是tarjan求lca+二分答案+树上差分(貌似不需要解释,看到这个思路就应该基本上会写了吧),实现起来也听简单的#include<bits/stdc++.h>using namespace std;const int N=300003;struct node{ int to,w,ne;}e[N<<1...原创 2018-05-31 20:24:55 · 313 阅读 · 0 评论 -
hdu5293 Tree chain problem
题目题解题意:有m条链,每条链链接两个顶点,链存在一个权值w,现在想要挑选一些链,挑选的链中不能出现相同的节点,问可以挑选出的最大的权重是多少Solution设dp[i]dp[i]dp[i]为以第iii个点位根节点的子树的最优解,sum[i]sum[i]sum[i]表示表示iii节点的所有子节点的dpdpdp和(注意:不包括iii)1.第iii个节点上不出现链,那么dp[i]=∑(dp[...转载 2018-10-29 09:07:12 · 287 阅读 · 0 评论 -
51nod 1470 计算机网络问题
题目题解Solution一个边双连通分量一定可以找到一个不走重复边的环这个的话用两个之间一定存在至少两条没有公共边的路径可以得证所以双连通分量的所有点是可以随便两两到达的于是我们可以先来一发双连通缩点然后就变成了一个树差分一下Code#include<bits/stdc++.h>using namespace std;const int N=200001;st...转载 2018-10-24 15:05:23 · 201 阅读 · 0 评论 -
bzoj3083: 遥远的国度
题目Solution1.x==rootx==rootx==root,查询整棵树。2.lca(root,x)!=xlca(root,x)!=xlca(root,x)!=x,查询xxx的子树3.lca(root,x)==xlca(root,x)==xlca(root,x)==x,查询与xxx相邻的节点中与rootrootroot最近的点vvv在整棵树中的补集注意:既然这题是树剖,那还打什么倍...原创 2018-10-27 14:58:33 · 109 阅读 · 0 评论