CCCPaste

Untitled

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
 

using namespace std;
vectorgraph[2000];
int idx[2000];
struct node{
int a;
int b;
int distance;
node(int _a, int _b, int _distance){
    a = _a;
    b = _b;
    distance = _distance;
}
bool operator < (const node &tmp)const{
return distance < tmp.distance;
}
};

int find_root(int a){
while(idx[a]!=a){
    idx[a]=idx[idx[a]];
    a=idx[a];
}
return a;
}


bool check(int a, int b){
if(find_root(a)!=find_root(b)){
    return false;
}
else{
    return true;
}
}

void unite_two_elements(int a, int b){
int _a=find_root(a);
int _b=find_root(b);
if(check(a, b)==false){
idx[_a]=_b;
}
}


int main()
{
    for(int i=0; i<2000; i++){
    idx[i]=i;
    }
    int n;
    cin>>n;
    vectorv;

    for(int i=0; i>a;
            v.push_back(node(i, j, a));
        }
    }

    sort(v.begin(), v.end());
    for(int i=0; i