QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#125533 | #415. 最小生成树 | yingmanji# | Compile Error | / | / | C++14 | 557b | 2023-07-16 20:10:37 | 2023-07-16 20:10:38 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-16 20:10:38]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-07-16 20:10:37]
- 提交
answer
#include <iostream>
using namespace std;
const int N=2e5+5;
int n,m,f[N],ans;
struct E{int u,v,w;}e[N];
inline int cmp(E x,E y){return x.w<y.w;}
inline int find(int x){return f[x]==x?f[x]:f[x]=find(f[x]);}
inline void merge(int a,int b){f[find(a)]=find(b);}
int main(int argc, char *argv[]) {
cin>>n>>m;
for(int i=1;i<=n;i++) f[i]=i;
for(int i=1;i<=m;i++) cin>>e[i].u>>e[i].v>>e[i].w;
sort(e+1,e+m+1,cmp);
for(int i=1;i<=m;i++){
if(find(e[i].u)!=find(e[i].v)){
merge(e[i].u,e[i].v);
ans+=e[i].w;
}
}
cout<<ans<<endl;
}
Details
answer.code: In function ‘int main(int, char**)’: answer.code:14:9: error: ‘sort’ was not declared in this scope; did you mean ‘short’? 14 | sort(e+1,e+m+1,cmp); | ^~~~ | short