#include <bits/stdc++.h>
#include "traffic.h"
using namespace std;
#define ll long long
#define uint unsigned int
#define ull unsigned long long
#define endl "\n"
#define elif else if
#define fo(i, a, b) for (int i = a; i < (int)b; i++)
#define rfo(i, a, b) for (int i = a - 1; i >= b; i--)
#define v(i) vector<i>
#define vll vector<long long>
#define vstr vector<string>
#define pairll pair<long long, long long>
#define vpairll vector<pair<long long, long long>>
#define print(x) cout << x << "\n"
#define pushall(x, n) \
x.resize(n); \
for (int zz = 0; zz < (int)n; zz++) \
{ \
cin >> x[zz]; \
}
const int MAX_N = 1e6 + 3e2;
vector<int> adj[MAX_N];
int dfss(int u, int p, int P[]) {
int ans = P[u];
for(int to : adj[u]) {
if(to == p) continue;
ans += dfss(to, u, P);
}
return ans;
}
int LocateCentre(int Nn, int P[], int S[], int D[]) {
int n = Nn;
for(int i = 0; i < N-1; i++) {
adj[S[i]].push_back(D[i]);
adj[D[i]].push_back(S[i]);
}
int ans = 2147483647, ret = -1;
for(int i = 0; i < N; i++) {
int max_traffic = -2147483648;
for(int to : adj[i]) {
max_traffic = max(max_traffic, dfss(to, i, P));
}
if(max_traffic < ans) {
ans = max_traffic;
ret = i;
}
}
return ret;
}
Compilation message
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:44:24: error: 'N' was not declared in this scope
44 | for(int i = 0; i < N-1; i++) {
| ^
traffic.cpp:50:24: error: 'N' was not declared in this scope
50 | for(int i = 0; i < N; i++) {
| ^
traffic.cpp:43:8: warning: unused variable 'n' [-Wunused-variable]
43 | int n = Nn;
| ^