#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define f first
#define s second
using namespace std;
int mod = 1e9+7;
ll inf = 1e18+5;
int n,m,size[205],link[205],reza1,reza2;
vector<pair<pii,pii>> putovi;
int find(int a){
if(link[a]==a)return a;
return link[a] = find(link[a]);
}
bool same(int a,int b){
return (find(a)==find(b));
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
for(int i = 0; i<205; i++){size[i]=1; link[i]=i;}
cin>>n>>m;
for(int i = 0; i<m; i++){
int a,b,c,d;
cin>>a>>b>>c>>d;
putovi.push_back({{c,d},{a,b}});
}
sort(putovi.begin(),putovi.end());
for(auto z : putovi){
int a = z.s.f;
int b = z.s.s;
if(same(a,b))continue;
a = find(a);
b = find(a);
if(size[a]>size[b])swap(a,b);
//size od a je manji od size od b
size[b]+=size[a];
link[a]=b;
reza1+=z.f.f;
reza2+=z.f.s;
}
cout<<reza1<<" "<<reza2<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
456 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
860 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
18 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
860 KB |
Output isn't correct |
20 |
Incorrect |
3 ms |
860 KB |
Output isn't correct |