随笔分类 - 生成树
摘要:problem给一张n个点m条边的有向图,每条边有一个正整数权值以及一种色光三原色红、绿、蓝之一的颜色。恰好选出k条边,满足只用这k条边之中的红色边和绿色边(或者蓝色边和绿色边)就能使n个点之间两两连通对于k==1…m,计算选出恰好k条满足条件的边的权值之和的最小值。...
阅读全文
摘要:problemsolutioncodes#include#include#define maxn 200020using namespace std;int n, m;struct UndirectedEdge{ int u, v, w; Undirect...
阅读全文
摘要:problemsolutioncodes//Kruskal#include#include#includeusing namespace std;int n, a[110][110], fa[110], co, ans;struct side{ int u, v...
阅读全文
摘要:problemsolutioncodes/*作者:gwj1139177410题目:p2627 村村通*///Kruskal#include#include#includeusing namespace std;int n, a[110][110], fa[110], ...
阅读全文
摘要:problemsolutioncodes//MST-Kruskal-排序贪心+并查集//题中N=M,(M小于N^2的)稀疏图用邻接表。#include#includeusing namespace std;typedef long long LL;const int ...
阅读全文
摘要:problemsolutioncodes//MST-Prim-贪心-堆优化#include#include#includeusing namespace std;const int maxn = 110;//Graphint e[maxn][maxn],ans;//P...
阅读全文
摘要:problemsolutioncodes#include#includeusing namespace std;struct side{ int u, v, w; }e[10010];bool cmp(const side &a, const side &b){ re...
阅读全文
摘要:problem给出一个连通无向图,判断它的最小生成树是否唯一如果唯一,输出生成树的大小,否则输出”Not Unique!”solution直接求非严格次小生成树如果次小生成树等于最小生成树则说明最小生成树不唯一,否则最小生成树一定是唯一的vector会TLE。。。co...
阅读全文
摘要:problemn个村庄,m条公路,建设每条公路需要时间t求多少时间后任意村庄通车solution最小生成树模板注意特判,无法连通输出-1codes#include#includeusing namespace std;struct side{ int u, v, w;...
阅读全文
摘要:problem给定一张图,求其最小生成树中的边数和权值最大的边solution裸的Kruskalcodes#include#includeusing namespace std;const int maxn = 10010;struct Edge{int u, v, ...
阅读全文
摘要:problemsolutioncodes//just for test2#include#includeusing namespace std;const int inf = 0xfffffff;int n, m, sx, ed, _max=inf, _min=1;i...
阅读全文