#include<bits/stdc++.h>
using namespace std;
long long n,m,ai,bi,ti,ci,sum,par[201];
vector<pair<int,int> >v[201];
vector<pair<long long,pair<int,int> > >edging;
int get(int x){
if(par[x]==x)return x;
return par[x]=get(par[x]);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
for(int i=0;i<n;i++)par[i]=i;
for(int i=0;i<m;i++){
cin>>ai>>bi>>ti>>ci;
v[ai].push_back({bi,ci});
v[bi].push_back({ai,ci});
edging.push_back({ci,{ai,bi}});
}
sort(edging.begin(),edging.end());
for(int i=0;i<m;i++){
long long ci=edging[i].first;
int ai=edging[i].second.first;
int bi=edging[i].second.second;
if(get(ai)!=get(bi)){
par[ai]=get(bi);
sum+=ci;
}
}
cout<<sum*sum;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - int64 expected |
2 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int64 expected |
3 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int64 expected |
4 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int64 expected |
5 |
Incorrect |
1 ms |
348 KB |
Unexpected end of file - int64 expected |
6 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int64 expected |
7 |
Incorrect |
1 ms |
348 KB |
Unexpected end of file - int64 expected |
8 |
Incorrect |
3 ms |
860 KB |
Unexpected end of file - int64 expected |
9 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int64 expected |
10 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int64 expected |
11 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int64 expected |
12 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - int64 expected |
13 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - int64 expected |
14 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int64 expected |
15 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int64 expected |
16 |
Incorrect |
1 ms |
348 KB |
Unexpected end of file - int64 expected |
17 |
Incorrect |
1 ms |
560 KB |
Unexpected end of file - int64 expected |
18 |
Incorrect |
1 ms |
344 KB |
Unexpected end of file - int64 expected |
19 |
Incorrect |
3 ms |
876 KB |
Unexpected end of file - int64 expected |
20 |
Incorrect |
3 ms |
860 KB |
Unexpected end of file - int64 expected |