Submission #1087083

#TimeUsernameProblemLanguageResultExecution timeMemory
1087083modwweRoad Closures (APIO21_roads)C++17
0 / 100
2059 ms67640 KiB
#pragma GCC optimize("Ofast,unroll-loops") #include<bits/stdc++.h> //#define int long long //#define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".ans","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; #define getchar_unlocked getchar inline int scan() { char c = getchar_unlocked(); int x = 0; while(c<'0'||c>'9') { c=getchar_unlocked(); } while(c>='0'&&c<='9') { x=(x<<1)+(x<<3)+c-'0'; c=getchar_unlocked(); } return x; } void phongbeo(); const int inf=1e9; const int mod2=1e9+9; const int mod1=998244353; struct icd { long double a; int b; }; struct ib { int a; int b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; struct ie { int a,b,c,d,e; }; int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,dem4,l,r,mid,l2,r2,center; int i,s10,s12; int kk; int el=29; int a[100001]; int b[100001]; vector<ib> v[100001]; vector<int> v2; void dfs(int x,int y) { for(auto f:v[x]) { if(f.a!=y) { a[f.a]=f.b; b[f.a]=f.b; dfs(f.a,x) ; } } } void dfs2(int x,int y) { for(auto f:v[x]) { if(f.a!=y) { dfs2(f.a,x); } } v2.clear(); for(auto f:v[x]) { if(f.a!=y) { v2.pb(a[f.a]); a[f.a]=b[f.a]; } } sort(v2.begin(),v2.end()); s5=0; s3=v[x].size(); for(int i=1; i<=s3-k; ++i) { s4+=v2[i-1]; s5=v2[i-1]; } a[x]-=s5; } vector<long long> minimum_closure_costs(int N,vector<int> U,vector<int> V,vector<int> W) { n=N; for(int i=1; i<n; i++) { //cin>>l>>r>>s2; l=U[i-1]; r=V[i-1]; s2=W[i-1]; l++; r++; v[l].pb({r,s2}); v[r].pb({l,s2}); s4+=s2; } dfs(1,0); for(int i=0; i<n; i++ ) { if(i!=0) k=i, dfs2(1,0); cout<<s4,down s4=0; } } /** 5 1 2 1 1 3 4 1 4 3 3 5 2 */

Compilation message (stderr)

roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:136:1: warning: no return statement in function returning non-void [-Wreturn-type]
  136 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...