제출 #362204

#제출 시각아이디문제언어결과실행 시간메모리
362204kshitij_sodani시간이 돈 (balkan11_timeismoney)C++14
5 / 100
5 ms1136 KiB
//#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({{aa,bb},{cc,dd}}); } sort(ed.begin(),ed.end()); 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 timeMemoryGrader output
Fetching results...