http://poj.org/problem id=1679
题目大意:
给你一些点,判断MST(最小生成树)是否唯一。
思路:
首先先建立MST,然后把这个MST的边一个个尝试不使用,构建另外一颗MST,然后判断权值是否相等。
这样复杂度需要O(n^3)。。
还可以用次最小生成树的方法解决。
#include#include using namespace std; const int MAXN=101; int fa[MAXN]; struct point { int x,y; int len; }data[MAXN*MAXN],pre[MAXN*MAXN]; //pre 记录等一下用到了哪些条边 bool operator < (const point &a ,const point &b) //sort 重载比较函数 { return a.len