#include<stdio.h> #include<algorithm> #include<windows.h> using namespace std; struct edge{ int begin; int end; int weight; }; bool cmp(struct edge a,struct edge b){ return a.weight<b.weight; } ]; ]; int find(int index){ ){ index=father[index]; } return index; } void minTree(int num){ ;i<num;i++){ int m=find(edges[i].begin); int n=find(edges[i].end); if(m!=n){ father[m]=n; printf("(%d %d)\n",edges[i].begin,edges[i].end); } } } int main(){ int n; scanf("%d",&n); ;i<n;i++){ scanf("%d%d%d",&edges[i].begin,&edges[i].end,&edges[i].weight); } printf("\n"); sort(edges,edges+n,cmp); minTree(n); }