# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
362205 | kshitij_sodani | timeismoney (balkan11_timeismoney) | C++14 | 6 ms | 1008 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#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... |