Submission #722327

#TimeUsernameProblemLanguageResultExecution timeMemory
722327Yell0Traffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; void dfs1(vector<vector<int>>& gr,vector<ll>& w,vector<ll>& st,vector<int>& pa,int u,int p) { st[u]=w[u]; pa[u]=p; for(int v:gr[u]) { if(v==p) continue; dfs1(gr,w,st,v,u); st[u]+=w[v]; } } void dfs2(vector<vector<int>>& gr,vector<ll>& st,vector<ll>& pw,int u,int p) { for(int v:gr[u]) { if(v==p) continue; pw[v]=pw[u]+st[u]-st[v]; dfs2(gr,st,pw,v,u); } } int LocateCentre(int N,int P[],int S[],int D[]) { vector<vector<int>> gr(N); for(int i=0;i<N-1;++i) { gr[S[i]].push_back(D[i]); gr[D[i]].push_back(S[i]); } vector<ll> w(P,P+N),st(N),pw(N),mw(N); vector<int> pa(N); dfs1(gr,w,st,pa,0,0); pw[0]=0; dfs2(gr,st,pw,0,0); ll cmw=LLONG_MAX; int ans=0; for(int u=0;u<N;++u) { ll mw=pw[u]; for(int v:gr[u]) if(v!=pa[u]) mw=max(mw,st[v]); if(mw<cmw) { ans=u; cmw=mw; } } return ans; }

Compilation message (stderr)

traffic.cpp: In function 'void dfs1(std::vector<std::vector<int> >&, std::vector<long long int>&, std::vector<long long int>&, std::vector<int>&, int, int)':
traffic.cpp:11:18: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'int'
   11 |     dfs1(gr,w,st,v,u);
      |                  ^
traffic.cpp:6:77: note: in passing argument 4 of 'void dfs1(std::vector<std::vector<int> >&, std::vector<long long int>&, std::vector<long long int>&, std::vector<int>&, int, int)'
    6 | void dfs1(vector<vector<int>>& gr,vector<ll>& w,vector<ll>& st,vector<int>& pa,int u,int p) {
      |                                                                ~~~~~~~~~~~~~^~