This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include<bits/stdc++.h>
usingnamespacestd;
constintINF=0x3f3f3f3f;
constintN=110;
intb[N];
intn,m;
intg[N][N];// 稠密图,邻接矩阵
intdis[N];// 这个点到集合的距离
boolst[N];// 是不是已经使用过
intres;// 最小生成树里面边的长度之和
intsum;// 总边长
// 普利姆算法求最小生成树
intprim(ints){
// 由于调用多次prim,所以每次需要清零
memset(dis,0x3f,sizeofdis);
dis[s]=0;
res=0;
// 标识
b[s]=1;
for(inti=0;i<n;i++){// 迭代n次
intt=-1;
for(intj=1;j<=n;j++)
if(!st[j]&&(t==-1||dis[t]>dis[j]))t=j;
// if (i && dis[t] == INF) return INF; // 非连通图,没有最小生成树