Submission #632252

#TimeUsernameProblemLanguageResultExecution timeMemory
632252deviceTraffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll a[1000000], ans, mn = INT_MAX; vector<int> adj[1000000]; void init(int cur, int par = -1){ for(int nxt:adj[cur]){ if(nxt == par) continue; init(nxt, cur); a[cur] += a[nxt]; } } void dfs(int cur, ll val = 0, int par = -1){ ll mx = val; for(int nxt:adj[cur]){ if(nxt == par) continue; mx = max(mx, a[nxt]); dfs(nxt, val + a[cur] - a[nxt], cur); } if(mx < mn){ mn = mx; ans = cur; } } int LocateCentre(n, p, s, d){ for(int i = 0; i < n; i++) a[i] = p[i]; for(int i = 0; i < n-1; i++){ adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } init(0); dfs(0); return ans; }

Compilation message (stderr)

traffic.cpp:25:18: error: 'n' was not declared in this scope; did you mean 'mn'?
   25 | int LocateCentre(n, p, s, d){
      |                  ^
      |                  mn
traffic.cpp:25:21: error: 'p' was not declared in this scope
   25 | int LocateCentre(n, p, s, d){
      |                     ^
traffic.cpp:25:24: error: 's' was not declared in this scope
   25 | int LocateCentre(n, p, s, d){
      |                        ^
traffic.cpp:25:27: error: 'd' was not declared in this scope
   25 | int LocateCentre(n, p, s, d){
      |                           ^
traffic.cpp:25:28: error: expression list treated as compound expression in initializer [-fpermissive]
   25 | int LocateCentre(n, p, s, d){
      |                            ^