首页 > TAG信息列表 > P1546

洛谷P1546 最短网络 Agri-Net(最小生成树,Kruskal)

洛谷P1546 最短网络 Agri-Net 最小生成树模板题。 直接使用 Kruskal 求解。 复杂度为 \(O(E\log E)\) 。 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; const int maxn = 105 * 105; int n, x, tot, ans, f[105]; struct edge{ int from

洛谷 P1546 最短网络 Agri-Net

题目传送门 解题思路: 一道裸的最小生成树,题解传送门 AC代码: 1 #include<cstdio> 2 #include<iostream> 3 #include<cstring> 4 5 using namespace std; 6 7 int n,g[101][101],dis[101],ans; 8 bool p[101]; 9 10 void Prim() {11 dis[1] = 0;12 p[1] = true;13

luogu P1546 最短网络 Agri-Net

emmm 题面不想放了 传送门www 一道emmm 很简单的最小生成树问题 没啥思维含量 不知道因为什么zz问题写了4遍www #include<cstdio> #include<algorithm> using namespace std; #define maxn 20010 int fa[maxn],n; int cnt,ans; struct EDGE { int to,from,weight; } edge[ma