求助报错

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
double b,c[100005],d,ans,l,k,l2;
struct code {
int a,b;
double w;
}e[100005];
int fa[100005];
inline bool cmp(code aa,code bb){
return aa.w<bb.w;
}
int find(int a){
int b=a,t;
while(fa[b]!=b) {b=fa[b];}
while(a!=b) {t=fa[a];fa[a]=b;a=t;}
return b;
}
int main()
{
for(int i=1;i<=1000;i++) {
fa[i]=i;
}
cin >> d >> l;
for(int i=1;;i++){
cin >> e[i].a;
if(e[i].a==0) {
l2=i-1;break;
}
else cin >> e[i].b >> e[i].w;
}
sort(e+1,e+l2+1,cmp);
for(int i=1,kk=0;i<=l2;i++){
int x=e[i].a;int y=e[i].b;
int fx=find(x);int fy=find(y);
if(fx!=fy){
fa[fx]=fy;kk++;ans+=e[i].w;
}
if(kk==d-k){
cout << "Need " << ans << " miles of cable";
return 0;
}
}
cout << "Impossible";
return 0;
}
其中 sort(e+1,e+l2+1,cmp); 报错:
[Error] invalid operands of types 'code [100005]' and 'double' to binary 'operator+'
求助。

0 条评论

目前还没有评论...

信息

ID
1045
难度
7
分类
树结构 点击显示
标签
(无)
递交数
4932
已通过
1000
通过率
20%
被复制
10
上传者