HDUOJ----1301 Jungle Roads】的更多相关文章

Jungle Roads 题目链接: http://acm.hust.edu.cn/vjudge/contest/124434#problem/A http://acm.hust.edu.cn/vjudge/contest/124434#problem/L Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on e…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1301 The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly,…
The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the large road network is too expensive to mainta…
题目: Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the large road network is too exp…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1301 //HDOJ1301 #include<iostream>#include<cstring> using namespace std; #define MAX 99999 #define LEN 30 int dist[LEN];//某点的权值 起始点到目标点的权值 int map[LEN][LEN];//某点到某点两点之间的权值 bool isvisitd[LEN];//表示某…
http://acm.hdu.edu.cn/showproblem.php?pid=1301 #include <cstdio> #include <cstring> #include <algorithm> #define maxn 500 using namespace std; <<; int g[maxn][maxn]; int dis[maxn]; bool vis[maxn]; int n,x,mm,sum; char ch,ch1; void…
地址:http://acm.hdu.edu.cn/showproblem.php?pid=1301 很明显,这是一道“赤裸裸”的最小生成树的问题: 我这里采用了Kruskal算法,当然用Prim算法也一样可以解题. #include <iostream> #include <cstring> #include <cstdio> #include <cstdlib> using namespace std; typedef struct node{ int f…
双向边,基础题,最小生成树   题目 同题目     #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include<string.h> #include <malloc.h> #include<stdlib.h> #include<algorithm> #include<iostream> using namespace std; #define inf 999999999 #…
题解 这是一道裸的最小生成树题,拿来练手,题目就不放了 个人理解  Prim有些类似最短路和贪心,不断找距当前点最小距离的点 Kruskal类似于并查集,不断找最小的边,如果不是一棵树的节点就合并为一颗树 AC代码: Prim算法: #include<iostream> #include<cstdio> //EOF,NULL #include<cstring> //memset #include<cstdlib> //rand,srand,system,it…
裸的最小生成树 输入很蓝瘦 **并查集 int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); } 找到x在并查集里的根结点,如果两个端点在同一个集合内,find之后两个值就相等了 每次找到权值最小的端点不在同一集合的边 把两个集合合并 #include <iostream> #include <cstdio> #include <algorithm> using namespace std; ];…