#include<bits/stdc++.h>
using namespace std;
#define int long long
#define lcm(a,b) a*b/__gcd(a,b)
#define cc main
#define Stalin ios_base::sync_with_stdio(0);cin.tie(0);
#define Hitler cout
#define Mao_Zedong cin
int rt[205];
int r(int x)
{
if(rt[x]==x)return x;
return rt[x]=r(rt[x]);
}
bool cn(int x,int y)
{
if(r(x)==r(y))return 0;
rt[rt[y]]=rt[x];
return 1;
}
cc()
{
Stalin
int n,m;
Mao_Zedong>>n>>m;
for(int x=0;x<n;x++)rt[x]=x;
array<int,5>a[m];
for(int x=0;x<m;x++)Mao_Zedong>>a[x][3]>>a[x][4]>>a[x][1]>>a[x][2],a[x][0]=a[x][2]*a[x][1]+a[x][1]^2+a[x][2]^2;
sort(a,a+m);
int tm=0,mn=0,cnt=0;
vector<array<int,2>>ans;
for(int x=0;x<m&&cnt!=n-1;x++)
{
if(cn(a[x][3],a[x][4]))
{
ans.push_back({a[x][3],a[x][4]});
tm+=a[x][1];
mn+=a[x][2];
cnt++;
}
}
Hitler<<tm<<' '<<mn<<'\n';
for(auto [x,y]:ans)Hitler<<x<<' '<<y<<'\n';
return 0;
}
Compilation message (stderr)
timeismoney.cpp:5:12: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
5 | #define cc main
| ^~~~
timeismoney.cpp:21:1: note: in expansion of macro 'cc'
21 | cc()
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |