网站开发详细设计文档模板,网站建设设计工具,搜盘网,怎么更改网站域名有趣 每条边在算答案的时候被算了二倍的边权值加上两个端点的权值#xff0c;然后睡觉点额外加一次 所以可以用这个权做MST#xff0c;然后加上点权最小的点 #includeiostream
#includecstdio
#includealgorithm
using namespace std;
const int N1…有趣 每条边在算答案的时候被算了二倍的边权值加上两个端点的权值然后睡觉点额外加一次 所以可以用这个权做MST然后加上点权最小的点 #includeiostream
#includecstdio
#includealgorithm
using namespace std;
const int N100005;
int n,m,a[N],f[N],ans1e9,con;
struct qwe
{int u,v,w;
}e[N];
bool cmp(const qwe a,const qwe b)
{return a.wb.w;
}
int read()
{int r0,f1;char pgetchar();while(p9||p0){if(p-)f-1;pgetchar();}while(p0p9){rr*10p-48;pgetchar();}return r*f;
}
int zhao(int x)
{return xf[x]?x:f[x]zhao(f[x]);
}
int main()
{nread(),mread();for(int i1;in;i){a[i]read();ansmin(ans,a[i]);f[i]i;}for(int i1;im;i){int xread(),yread(),zread()*2a[x]a[y];e[i](qwe){x,y,z};}sort(e1,em1,cmp);for(int i1;imconn-1;i){int fuzhao(e[i].u),fvzhao(e[i].v);if(fu!fv){f[fu]fv;con;anse[i].w;}}printf(%d,ans);return 0;
} 转载于:https://www.cnblogs.com/lokiii/p/8963826.html