闰土
#include<bits/stdc++.h>
using namespace std;
typedef long long lld;
struct var
{
int x,y;lld ccf;
var(){}
var(int a,int b,lld c)
{x=a;y=b;ccf=c;}
};var rd[10005];
bool cmp(var a,var b)
{return a.ccf<b.ccf;}
int f[2005];
int find(int x)
{
if(f[x]==x)
return x;
return f[x]=find(f[x]);
}
void uni(int x,int y)
{f[find(x)]=find(y);}
int main()
{
int n,m;cin>>n>>m;
for(int i=1;i<=n;f[i]=i++);
for(int i=1;i<=m;++i)
{
int a,b;lld c;
cin>>a>>b>>c;
rd[i]=var(a,b,c);
}
sort(rd+1,rd+m+1,cmp);
lld out=0;int tot=0;
for(int i=1;i<=m;++i)
{
if(find(rd[i].x)^find(rd[i].y))
{
uni(rd[i].x,rd[i].y);
++tot;out=rd[i].ccf;
}
if(tot==n-1)break;
}
cout<<out;
}