# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
333899 | Aldew | Traffic (IOI10_traffic) | C++14 | 1175 ms | 159040 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.
/*
ID: alec3
LANG: C++14
PROG:
/*
Credit to Oscar Garries
*/
#include <bits/stdc++.h>
#define check(x) cout<<(#x)<<": "<<x<<" " << endl;
#define line cout << "--------------" << endl;
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define all(c) (c).begin(), (c).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define F0R(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
int pct(int x) { return __builtin_popcount(x); }
using namespace std;
void setIO(string name) {
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
ios_base::sync_with_stdio(0);
}
int fans = 0;
vector<int> adj[(int)1e6], nodes(1e6), people(1e6), children(1e6);
void dfs(int v, int parent){
for (auto x : adj[v]){
if (x == parent)
continue;
dfs(x, v);
children[v] += children[x];
people[v] = max(people[v], children[x]);
}
people[v] = max(people[v], fans-children[v] - nodes[v]);
children[v] += nodes[v];
return;
}
int LocateCentre (int n, int p[], int d[], int s[]){
F0R(i, n){
fans += p[i];
nodes[i] = p[i];
}
F0R(i, n-1){
adj[s[i]].pb(d[i]);
adj[d[i]].pb(s[i]);
}
dfs(0, -1);
int sol = INT_MAX, ans = -1;
F0R(i, n){
if (people[i] < sol){
ans = i;
sol = people[i];
}
}
return ans;
}
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... |