Submission #1029220

#TimeUsernameProblemLanguageResultExecution timeMemory
1029220lucritimeismoney (balkan11_timeismoney)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; long long t[210],u[10010],v[10010],ti[10010],mo[10010],n,m,vmax=2000000000000000000,st,sm,p1,p2; long long sumt,summ; struct muchii{long long u,v,val,valt,valm;}a[10010]; long long tata(long long n) { if(t[n]==n)return n; return t[n]=tata(t[n]); } long long x,xx,y,yy; bool comp(muchii a,muchii b) { if(a.val!=b.val)return a.val<b.val; if(a.u!=b.u)return a.u<b.u; if(a.v!=b.v)return a.v<b.v; return a.valt<b.valt; } void calculeaza(long long v1,long long v2) { for(long long i=0;i<n;++i) t[i]=i; for(long long i=1;i<=m;++i) a[i]={u[i],v[i],ti[i]*v1+mo[i]*v2,ti[i],mo[i]}; sumt=summ=0; sort(a+1,a+m+1,comp); for(long long i=1;i<=m;++i) { if(tata(a[i].u)!=tata(a[i].v)) { t[t[a[i].u]]=t[a[i].v]; sumt+=a[i].valt; summ+=a[i].valm; } } } void scrie(long long v1,long long v2) { for(long long i=0;i<n;++i) t[i]=i; for(long long i=1;i<=m;++i) a[i]={u[i],v[i],ti[i]*v1+mo[i]*v2,ti[i],mo[i]}; sort(a+1,a+m+1,comp); for(long long i=1;i<=m;++i) { if(tata(a[i].u)!=tata(a[i].v)) { t[t[a[i].u]]=t[a[i].v]; cout<<a[i].u<<' '<<a[i].v<<'\n'; } } } long long det(long long x,long long y,long long xx,long long yy,long long xxx,long long yyy) { return x*yy+xx*yyy+xxx*y-xx*y-xxx*yy-x*yyy; } bool imbunatatire() { calculeaza(abs(yy-y),abs(xx-x)); if(sumt*summ<vmax) { st=sumt,sm=summ; vmax=sumt*summ; p1=abs(yy-y); p2=abs(xx-x); } if(det(x,y,xx,yy,sumx,sumy)==0) return false; return true; } int main() { cin>>n>>m; for(long long i=1;i<=m;++i) cin>>u[i]>>v[i]>>ti[i]>>mo[i]; calculeaza(1,0); if(sumt*summ<vmax) { st=sumt,sm=summ; vmax=sumt*summ; p1=1; p2=0; } x=sumt; y=summ; calculeaza(0,1); if(sumt*summ<vmax) { st=sumt,sm=summ; vmax=sumt*summ; p1=0; p2=1; } xx=sumt; yy=summ; while(imbunatatire()) { x=xx; y=yy; xx=sumt; yy=summ; } cout<<st<<' '<<sm<<'\n'; scrie(1,1); return 0; }

Compilation message (stderr)

timeismoney.cpp: In function 'bool imbunatatire()':
timeismoney.cpp:67:22: error: 'sumx' was not declared in this scope; did you mean 'summ'?
   67 |     if(det(x,y,xx,yy,sumx,sumy)==0)
      |                      ^~~~
      |                      summ
timeismoney.cpp:67:27: error: 'sumy' was not declared in this scope; did you mean 'summ'?
   67 |     if(det(x,y,xx,yy,sumx,sumy)==0)
      |                           ^~~~
      |                           summ