
kruskal
Ceyo
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【NOIP2013提高组】货车运输
做法:克鲁斯卡尔+倍增LCA #include<cstdio> #include<algorithm> using namespace std; struct street {int u,v,z;}a[50010]; struct node {int v,fr,z;}e[20010]; int tail[10010],fa[10010],dep[10010]; int f[.原创 2019-01-01 12:04:35 · 282 阅读 · 0 评论 -
【NOIP2012模拟8.10】生成输入数据
这题可以很容易就想到, 由于我们要将最小生成树变成原来的完全图,而且要使边权和最小。 那么:如果我们在x和y连一条边,那么这条边的长度变为↙ 那个最小生成树中x到y的路径上最大的边权+1。 这样子暴力O(n2),只能拿50分。 我们考虑优化。(用并查集) 模拟一遍最小生成树,每次合并的时候记录一下每块的个数,并添加答案。 上标: #include<cstdio> #include<...原创 2019-01-19 12:45:31 · 283 阅读 · 0 评论