# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
362205 | kshitij_sodani | 시간이 돈 (balkan11_timeismoney) | C++14 | 6 ms | 1008 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl '\n'
llo n,m;
llo par[201];
llo find(llo no){
if(par[no]==no){
return no;
}
par[no]=find(par[no]);
return par[no];
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m;
for(int i=0;i<n;i++){
par[i]=i;
}
vector<pair<pair<llo,llo>,pair<llo,llo>>> ed;
for(llo i=0;i<m;i++){
llo aa,bb,cc,dd;
cin>>aa>>bb>>cc>>dd;
ed.pb({{cc,dd},{aa,bb}});
}
sort(ed.begin(),ed.end());
for(int i=0;i<m;i++){
swap(ed[i].a,ed[i].b);
}
vector<pair<llo,llo>> ans;
llo su=0;
llo su2=0;
for(auto j:ed){
llo x=find(j.a.a);
llo y=find(j.a.b);
if(x!=y){
par[x]=y;
su+=j.b.a;
su2+=j.b.b;
ans.pb(j.a);
}
}
cout<<su<<" "<<su2<<endl;
for(auto j:ans){
cout<<j.a<<" "<<j.b<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |