#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF (1<<30) #define INFLL (1ll<<60) typedef pair P; typedef pair E; #define MOD (1000000007ll) #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } void add_mod(ll& a, ll b){ b += MOD; a += b; a %= MOD; } int ufp[100100],ufr[100100],a[100100],b[100100]; ll c[100100]; bool f[100100]; vector

v; void ufinit(int n){ int i; for(i=0; i ufr[y]){ ufp[y] = x; }else{ ufp[x] = y; if(ufr[x]==ufr[y]){ ++ufr[y]; } } } bool comp(P a, P b){ return (a.first> n >> m >> k; ufinit(n); for(i=0; i> a[i] >> b[i] >> c[i]; --a[i]; --b[i]; v.push_back(P(c[i],i)); } sort(v.begin(),v.end(),comp); for(i=0; i> e; --e; f[e] = true; unionf(a[e],b[e]); } for(i=0; i