https://www.lydsy.com/JudgeOnline/problem.php?id=1083
题意:给你一个图,求生成树最大边权最小值
就是求瓶颈生成树(生成树中最大边权最小),最小生成树一定是瓶颈生成树,但是瓶颈生成树不一定是最小生成树,最小瓶颈生成树一定是最小生成树
/**************************************************************
Problem: 1083
User: walfy
Language: C++
Result: Accepted
Time:40 ms
Memory:2420 kb
****************************************************************/ //#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define cd complex<double>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0) using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=N*N+,inf=0x3f3f3f3f,INF=0x3f3f3f3f3f3f3f3f; struct edge{
int u,v,c;
bool operator <(const edge&rhs)const{
return c<rhs.c;
}
}e[maxn];
int fa[N];
int Find(int x)
{
return fa[x]==x?x:fa[x]=Find(fa[x]);
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)fa[i]=i;
for(int i=;i<m;i++)scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].c);
sort(e,e+m);
int ans=;
for(int i=;i<m;i++)
{
int x=e[i].u,y=e[i].v;
int fx=Find(x),fy=Find(y);
if(fx!=fy)
{
fa[fx]=fy;
ans=max(ans,e[i].c);
}
}
printf("%d %d\n",n-,ans);
return ;
}
/*********************** ***********************/