Submission #370898

#TimeUsernameProblemLanguageResultExecution timeMemory
370898XEMPLI5Traffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; int fans, mxN = 1e6 vector<vector<int>> g(mxN); vector<int> citySize(mxN), subTreeSize(mxN), maxTraffic(mxN), people(mxN); void dfs(int cur, int par){ subTreeSize[cur] = citySize[cur]; for(auto e: g[cur]) { if(e == par) return; dfs(e,par); subTreeSize[cur] += subTreeSize[e]; people[cur] = max(people[cur], subTreeSize[e]); } people[cur] = max(people[cur], fans - subTreeSize[cur]); } int LocateCentre(int n, int p[], int s[], int d[]){ for(int i=0; i<n; i++){ g[s[i]].push_back(d[i]); g[d[i]].push_back(s[i]); } for(int i=0; i<n; i++) { fans += p[i]; citiySize[i] = p[i]; } dfs(0,0); int ans = 0, minPeople = 1e9; for(int i=0; i<n; i++){ if(people[i] < minPeople) { minPeople = people[i]; ans = i; } } return ans; }

Compilation message (stderr)

traffic.cpp:7:1: error: expected ',' or ';' before 'vector'
    7 | vector<vector<int>> g(mxN);
      | ^~~~~~
traffic.cpp: In function 'void dfs(int, int)':
traffic.cpp:12:14: error: 'g' was not declared in this scope
   12 |  for(auto e: g[cur]) {
      |              ^
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:25:3: error: 'g' was not declared in this scope
   25 |   g[s[i]].push_back(d[i]);
      |   ^
traffic.cpp:30:3: error: 'citiySize' was not declared in this scope; did you mean 'citySize'?
   30 |   citiySize[i] = p[i];
      |   ^~~~~~~~~
      |   citySize