题目: Out of Hay Time Limit: 1000MS Memory Limit: 65536K Total Submissions: Accepted: Description The cows have run <= N <= ,) farms (numbered ..N); Bessie starts at Farm . She'll traverse some or all of the M (1 <= M <= 10,000) two-way roads wh…
#include<stdio.h> #include<string.h> using namespace std; int map[505][505]; int v, e; int prime() { bool vis[505]; int dist[505]; int i,j,sum=0; for(i=1;i<=v;i++) { vis[i]=0; //先假设编号为1的点加入MST dist[i]=map[1][i]; } vis[1]=1; for(i=1;i<v;i…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1233 可以用Kruskal来做,不过当图的边比较稠密的时候用prime会更快一些. AC代码:296MS #include <iostream> #include <cstring> #include <cstdio> using namespace std; const int inf=0xffffff; int dis[105],sum,n; int weight[105]…
题目: http://acm.hdu.edu.cn/showproblem.php?pid=1863 注意有可能出现无法生成树的情况. #include <iostream> #include <cstring> using namespace std; const int inf=0xffffff; int weight[105][105],n,m; int prime() { int sum=0; int pre[105]; int dis[105]; bool visit[1…
还是畅通project Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 26860 Accepted Submission(s): 11985 Problem Description 某省调查乡村交通状况,得到的统计表中列出了随意两村庄间的距离.省政府"畅通project"的目标是使全省不论什么两个村庄间都能够实现公路交…