又是求次小生成树,就是求出最小生成树,然后枚举不在最小生成树上的每条边,求出包含着条边的最小生成树,然后取一个最小的
#include#include #include #include #include #include #include #include #include #include using namespace std;const int N=105;const int INF=0x3f3f3f3f;int fa[N],head[N],tot,T,n,m,d[N][N];struct Edge{ int v,next,w;}edge[N<<1];void add(int u,int v,int w){ edge[tot].v=v; edge[tot].w=w; edge[tot].next=head[u]; head[u]=tot++;}struct Node{ int u,v,w; bool mark; bool operator<(const Node &rhs)const{ return w