Submission #395601

#TimeUsernameProblemLanguageResultExecution timeMemory
395601garnab27Traffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll int64_t using namespace std; vector<ll > sum; vector<ll > ans; vector<int> g[1000006]; ll dfs1(int u, int p, int pp[]) { sum[u] += pp[u]; for(int v: g[u]) { if(v != p) { sum[u] += dfs1(v, u); } } return sum[u]; } void dfs2(int u, int p, ll psum, int pp[]) { ans[u] = 0; ll csum = pp[u]; if(p != -1) { ans[u] = max(ans[u], psum); csum += psum; } for(int v: g[u]) { if(v != p) { csum += sum[v]; ans[u] = max(ans[u], sum[v]); } } for(int v: g[u]) { if(v != p) { dfs2(v, u, csum - sum[v]); } } } int LocateCentre(int N, int pp[], int S[], int D[]) { sum.resize(N); ans.resize(N); for(int i=0;i<N-1;i++) { g[S[i]].pb(D[i]); g[D[i]].pb(S[i]); } dfs1(0, -1, pp); dfs2(0, -1, 0, pp); int id = 0, mn = ans[0]; for(int i=1;i<N;i++) { if(mn > ans[i]) { mn = ans[i]; id = i; } } return id; }

Compilation message (stderr)

traffic.cpp: In function 'int64_t dfs1(int, int, int*)':
traffic.cpp:14:23: error: too few arguments to function 'int64_t dfs1(int, int, int*)'
   14 |    sum[u] += dfs1(v, u);
      |                       ^
traffic.cpp:9:4: note: declared here
    9 | ll dfs1(int u, int p, int pp[]) {
      |    ^~~~
traffic.cpp: In function 'void dfs2(int, int, int64_t, int*)':
traffic.cpp:37:28: error: too few arguments to function 'void dfs2(int, int, int64_t, int*)'
   37 |    dfs2(v, u, csum - sum[v]);
      |                            ^
traffic.cpp:21:6: note: declared here
   21 | void dfs2(int u, int p, ll psum, int pp[]) {
      |      ^~~~
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:47:14: error: 'class std::vector<int>' has no member named 'pb'
   47 |      g[S[i]].pb(D[i]);
      |              ^~
traffic.cpp:48:14: error: 'class std::vector<int>' has no member named 'pb'
   48 |      g[D[i]].pb(S[i]);
      |              ^~