Submission #1188590

#TimeUsernameProblemLanguageResultExecution timeMemory
1188590ziyad_alharbitimeismoney (balkan11_timeismoney)C++20
50 / 100
2097 ms840 KiB
#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 array<int,5>a[10005]; int rt[205],n,m; int tm2=1e5,mn2=1e5; int tm1=1e5,mn1=1e5,cnt=0; vector<array<int,2>>ans1,ans2; 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; } void in() { for(int x=0;x<=n;x++)rt[x]=x; } void f() { if(tm1*mn1<=tm2*mn2) { tm2=0; mn2=0; cnt=0; in(); ans2.clear(); for(int x=0;x<m&&cnt!=n-1;x++) { if(cn(a[x][3],a[x][4])) { ans2.push_back({a[x][3],a[x][4]}); tm2+=a[x][1]; mn2+=a[x][2]; cnt++; } } } else { tm1=0; mn1=0; cnt=0; in(); ans1.clear(); for(int x=0;x<m&&cnt!=n-1;x++) { if(cn(a[x][3],a[x][4])) { ans1.push_back({a[x][3],a[x][4]}); tm1+=a[x][1]; mn1+=a[x][2]; cnt++; } } } } cc() { Stalin Mao_Zedong>>n>>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]; } sort(a,a+m); f(); for(int x=0;x<m;x++)a[x][0]=a[x][1]; sort(a,a+m); f(); for(int x=0;x<m;x++)a[x][0]=a[x][1]+a[x][2]; sort(a,a+m); f(); for(int x=1;x<=140;x++) { for(int y=1;y<=140;y++) { for(int x=0;x<m;x++)a[x][0]=a[x][1]+a[x][2]; sort(a,a+m); f(); } } if(tm2*mn2<=tm1*mn1) { Hitler<<tm2<<' '<<mn2<<'\n'; for(auto [x,y]:ans2)Hitler<<x<<' '<<y<<'\n'; } else { Hitler<<tm1<<' '<<mn1<<'\n'; for(auto [x,y]:ans1)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:68:1: note: in expansion of macro 'cc'
   68 | cc()
      | ^~
#Verdict Execution timeMemoryGrader output
Fetching results...