摘要: 题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1875//9403289 2013-10-24 17:00:49 Accepted 1875 62MS 376K 2205 B C++ 空信高手#include #include #include using namespace std;#define typec double#define V 101const typec inf=10000000;int vis[V];typec lowc[V],cost[V][V];typedef struct... 阅读全文
posted @ 2013-10-24 17:37 西芒xiaoP 阅读(234) 评论(0) 推荐(0)
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1102分析:看到这题给出的都是矩阵形式,就知道了可以用Prim算法求MST。#include using namespace std;#define typec int#define V 101const typec inf=0x3f3f3f3f;int vis[V];typec lowc[V],cost[V][V];/*=================================================*\ | Prim求MST | INIT: cost[][]耗费矩阵(inf为无穷大) 阅读全文
posted @ 2013-10-24 15:32 西芒xiaoP 阅读(183) 评论(0) 推荐(0)
摘要: PRIM==>>MST模板#include using namespace std;#define typec int#define V 3const typec inf=0x3f3f3f3f;int vis[V];typec lowc[V];/*==================================================*\ | Prim求MST | INIT: cost[][]耗费矩阵(inf为无穷大); | CALL: prim(cost, n); 返回-1代表原图不连通;\*====================================== 阅读全文
posted @ 2013-10-24 14:49 西芒xiaoP 阅读(180) 评论(0) 推荐(0)
摘要: 并查集+kruskal==>MST效率很低#include using namespace std;#define MAX 105 //自己设置最大值// father[x]表示x的父节点int father[MAX];// rank[x]表示x的秩int rank[MAX];typedef struct{ int i,j; int distance;} E;E edges[MAX*MAX];// 初始化void Make_Set(int n){ for(int i=1; i rank[y]) father[y] = x; else if(rank[x... 阅读全文
posted @ 2013-10-24 10:56 西芒xiaoP 阅读(229) 评论(0) 推荐(0)