~~变量名太长~~
~~苏联不吼~~
@[lmszs](/space/show?uid=25453)
by 355_113 @ 2017-05-25 17:55:31
数组开小了。@[lmszs](/space/show?uid=25453)
by 355_113 @ 2017-05-25 17:57:13
@[355\_113](/space/show?uid=41920)
已解决,没开小
init中
by lmszs @ 2017-05-25 18:01:19
@[lmszs](/space/show?uid=25453) 。。。
by 355_113 @ 2017-05-25 18:02:22
@[355\_113](/space/show?uid=41920) 你自己去好好找找,你个辣鸡
by lmszs @ 2017-05-25 18:21:51
@[lmszs](/space/show?uid=25453) 我怎么交都不对。。。难道是我太傻。。。
m改成n了。。。
by 355_113 @ 2017-05-25 18:33:04
@[lmszs](/space/show?uid=25453) 噫。你才是辣鸡。
by 355_113 @ 2017-05-25 18:36:44
@[lmszs](/space/show?uid=25453) mdzz我只是把你那个苏联函数名字改成zz就wa了。。。
by 355_113 @ 2017-05-25 18:39:19
```cpp
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<ctime>
using namespace std;
long long father[200001],n,m1,m2,m3,tot,ji,w,k;
int find(int x)
{
if(father[x]!=x)
father[x]=find(father[x]);
return father[x];
}
struct sb
{
int x;
int y;
int z;
}zz[200001];
int cmp(const sb &a,const sb &b)
{
if(a.z<b.z)
return 1;
else
return 0;
}
int main()
{
cin>>k>>n;
for(int i=1;i<=n;i++)
{
cin>>m1>>m2>>m3;
w++;
zz[w].x=m1;
zz[w].y=m2;
zz[w].z=m3;
}
for(int i=1;i<=k;i++)
father[i]=i;
sort(zz+1,zz+w+1,cmp);
int a1,a2;
for(int i=1;i<=w;i++)
{
a1=find(zz[i].x);
a2=find(zz[i].y);
if(a1!=a2)
{
ji=ji+zz[i].z;
tot++;
father[a2]=a1;
}
if(tot==k-1)
{
cout<<ji;
return 0;
}
}
cout<<"orz";
return 0;
}
```
by zhy12138 @ 2017-05-31 23:09:03