# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
252837 |
2020-07-26T10:42:37 Z |
SamAnd |
Traffic (IOI10_traffic) |
C++17 |
|
0 ms |
0 KB |
#include "grader.h"
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;
const int N = 1000003,INF=2000000001;
int n;
vector<pair<int,int> > a[N];
int b[N];
int sum, ans = INF, ansi;
int dfs(int x, int p)
{
int res=0;
int yans=0;
for (int i = 0; i < a[x].size(); ++i)
{
int h = a[x][i].first;
if (h == p)
continue;
a[x][i].second = dfs(h,x);
res += a[x][i].second;
yans = max(yans, a[x][i].second);
}
yans = max(yans, sum - res - b[x]);
if (yans < ans)
{
ans = yans;
ansi = x;
}
return res + b[x];
}
int LocateCentre(int N, int pp[], int S[], int D[]) {
n = N;
for (int i = 0; i < n; ++i)
{
b[i] = pp[i];
sum += b[i];
}
for (int i = 0; i < n - 1; ++i)
{
a[S[i]].push_back(make_pair(D[i],0));
a[D[i]].push_back(make_pair(S[i],0));
}
dfs(0,-1);
return ansi;
}
Compilation message
traffic.cpp:1:10: fatal error: grader.h: No such file or directory
#include "grader.h"
^~~~~~~~~~
compilation terminated.