# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
585744 | Hanksburger | Traffic (IOI10_traffic) | C++17 | 1058 ms | 167600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "traffic.h"
#include <bits/stdc++.h>
using namespace std;
int res[1000005], sz[1000005], sum;
vector<int> adj[1000005];
void dfs(int u, int p)
{
for (int i=0; i<adj[u].size(); i++)
{
int v=adj[u][i];
if (v==p)
continue;
dfs(v, u);
res[u]=max(res[u], sz[v]);
sz[u]+=sz[v];
}
res[u]=max(res[u], sum-sz[u]);
}
int LocateCentre(int n, int p[], int x[], int y[])
{
for (int i=0; i<n; i++)
sum+=sz[i]=p[i];
for (int i=0; i<n-1; i++)
{
adj[x[i]].push_back(y[i]);
adj[y[i]].push_back(x[i]);
}
dfs(0, -1);
int ind=0, mn=2e9;
for (int i=0; i<n; i++)
{
if (mn>res[i])
{
mn=res[i];
ind=i;
}
}
return ind;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |