Submission #503203

#TimeUsernameProblemLanguageResultExecution timeMemory
503203Hacv16Traffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "traffic.h" using namespace std; const int MAX = 1e6 + 15; const int INF = 0x3f3f3f3f; int fans = 0; vector<int> adj[MAX], child(MAX), cong(MAX), fan(MAX); void dfs(int x, int p){ for(auto v : adj[x]){ if(v == p) continue; dfs(v, x); child[x] += child[v]; cong[x] = max(cong[x], child[v]); } cong[x] = max(cong[x], fans - child[x] - fan[x]); child[x] += fan[x]; } int LocateCentre(int n, int p[], int s[], int d[]){ for(int i = 0; i < n; i++){ fans += p[i]; fan[i] = p[i]; } for(int i = 0; i < n - 1; i++){ adj[s[i]].pb(d[i]); adj[d[i]].pb(s[i]); } dfs(0, -1); int id = -1, sm = INF; for(int i = 0; i < n; i++){ if(cong[i] < sm){ id = i, sm = cong[i]; } } return id; }

Compilation message (stderr)

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:32:19: error: 'class std::vector<int>' has no member named 'pb'
   32 |         adj[s[i]].pb(d[i]);
      |                   ^~
traffic.cpp:33:19: error: 'class std::vector<int>' has no member named 'pb'
   33 |         adj[d[i]].pb(s[i]);
      |                   ^~