Constructing Roads Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1102 Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two vill…
最小生成树水题.prim一次AC #include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include <cctype> #include <cmath> #include <algorithm> #include <numeric> #define typec int using namespace std;…
爽爆.史上个人最快MST的记录7分40s..一次A. #include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #include <cctype> #include <algorithm> #include <numeric> #define typec int using names…
//克鲁斯卡尔(最小生成树) #include<cstdio> #include<iostream> #include<algorithm> using namespace std; ; int n, t; struct node { int bagin, end, len; }arr[maxn]; int fa[maxn]; void init() { ; i <= n; i++) { fa[i] = i; } } bool cmp(node a, node b…
很基础的点坐标MST,一不留神就AC了, - - !! #include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #include <cctype> #include <algorithm> #include <numeric> #include <limits.h> #d…
Problem Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected, if and only if there is a road between A and B…
真心大水题...不多说. #include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include <cctype> #include <cmath> #include <algorithm> #include <numeric> #define typec int using namespace std; cons…
无坑,裸题.直接敲就恩那个AC. #include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <cctype> #include <algorithm> #include <numeric> #define typec int using namespace std; ; const int inf = 0xffff;…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1102 题解: 纯最小生成树,只是有些边已经确定了要加入生成树中,特殊处理一下这些边就可以了. kruskal算法: 由于有些边已经确定,所以在调用kruskal()之前,就把这条边的两个顶点放在一个集合就可以了. #include<cstdio>//hdu1102 最小生成树 kruskal #include<algorithm> #define N 110 using namespa…
注意输入的数据分别是做什么的就好.还有,以下代码用C++交可以过,而且是500+ms,但是用g++就会TLE,很奇怪. #include <iostream> #include <cstring> #include <cstdio> #include <cstdlib> #include <cmath> #include <cctype> #include <algorithm> #include <numeric&…