思路: 不要把这道题想得太复杂,其实就是插排加最小生成树暴力,可以卡过 c o d e code code #include<iostream> #include<cstdio> #include<algorithm> using namespace std; int n, m; struct node { int x, y, z; }a[10010]; int fa[1000]; int find(int x) { if(x==fa[x