#include "grader.h"
#include "traffic.h"
#include <vector>
#include <iostream>
using namespace std;
int const nmax = 1000000;
char v[1 + nmax * 2];
int v[1 + nmax], sum[1 + nmax];
int far[1 + nmax];
vector<int> g[1 + nmax];
void dfs(int node, int parent){
far[node] = parent;
sum[node] = v[node];
for(int h = 0; h < g[node].size(); h++){
int to = g[node][h];
if(to != parent) {
dfs(to, node);
sum[node] += sum[to];
}
}
}
int eval(int node){
int result = sum[1] - sum[node];
for(int h = 0; h < g[node].size(); h++){
int to = g[node][h];
if(to != far[node])
result = max(result, sum[to]);
}
return result;
}
int LocateCentre(int n, vector<int> p, vector<int> s, vector<int> d){
for(int i = 0; i < n; i++){
s[i]++;
d[i]++;
g[s[i]].push_back(d[i]);
g[d[i]].push_back(s[i]);
}
for(int i = 1;i <= n; i++)
v[i] = p[i - 1];
dfs(1, 0);
pair<int,int> sol(eval(1), 1);
for(int i = 2;i <= n; i++){
pair<int,int> candidate(eval(i), i);
sol = min(sol, candidate);
}
return candidate.second;
}
Compilation message
traffic.cpp:1:10: fatal error: grader.h: No such file or directory
#include "grader.h"
^~~~~~~~~~
compilation terminated.