![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
最小生成树(MST)
文章平均质量分 65
morninghapppy
这个作者很懒,什么都没留下…
展开
-
zoj 2326
最小生成树题目…… #include #include #include struct paths { char x[21]; char y[21]; float dis; }path[400]; int cmp(const void *a,const原创 2011-08-19 17:56:21 · 224 阅读 · 0 评论 -
zoj 3321
错误的连接情况有很多种,缺少边,边多了,有子环结构(整体是个环,内部又有小环;整体不是环,而是两个或更多个环); 我觉得最方便的还是用链表吧,记录前一个和后一个,找一个结点作为起始点,检查最后是否构成一个环; #include struct node { int nu原创 2011-08-19 18:06:38 · 351 阅读 · 0 评论 -
zoj 1789
第一次写的代码超时了……这是错误代码#include struct student //用数组更方便一点儿 { int t; int father; }student[30000]; int find(int x) { if(student[x原创 2011-08-19 17:10:36 · 486 阅读 · 0 评论 -
zoj 1406
这道题目做的时候,把cmp 函数的定义写到main 函数里了,结果一直编译不过,唉,真挫…… 输入数据中既有字母又有数字,读入数据要细心些,注意空格、换行符。 #include #include struct road { char fomer; char原创 2011-08-19 17:38:31 · 546 阅读 · 0 评论 -
zoj 1372
最小生成树的题目,用到查并集,本题要求出连接所有点的最短路径。 首先,对于每条边用结构体存储,记录两个顶点和两点间的距离; 然后就是最小生成树的核心思想:每一次选取最小的那条边,如果该边的两个点尚未连通(两个点不在一个集合),那么就连接两个点,否则,不用这条边; 每次连接两原创 2011-08-19 17:31:13 · 328 阅读 · 0 评论 -
zoj 2048
输出的时候好像要排下序~ If no new highways need to be built (all towns are already connected), then the output should be created but it should be emp原创 2011-08-19 17:52:03 · 542 阅读 · 0 评论 -
HDU 1213
#include int find(int *a,int x) { if(a[x]==x) return x; else return find(a,a[x]); } void merge(int *a,int x,int y) { a[x]=y原创 2011-08-19 17:14:09 · 252 阅读 · 0 评论