Vijos 1234 pockets of the sky

Source: Internet
Author: User

Minimum spanning Tree kruscal algorithm

#include <iostream> #include <algorithm> #include <cstring> #define MAXN 10005using namespace std; struct stu{int x,y;int t;}; Stu Mapp[maxn];int f[1005];int n,m,k,sum,flag;bool cmp (stu X,stu y) {return x.t<y.t;} int  dfs (int x) {if (f[x]!=x) F[x]=dfs (f[x]); return f[x];} void build (int x) {if (Dfs (mapp[x].x)!=dfs (mapp[x].y)) {F[dfs (mapp[x].x)]=dfs (MAPP[X].Y); sum+=mapp[x].t;}} int solve () {int re=0;for (int i=1;i<=n;i++) {if (f[i]==i) re++;}  


Vijos 1234 pockets of the sky

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.