# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
376903 | 54skyxenon | Traffic (IOI10_traffic) | C++11 | 18 ms | 23788 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 <iostream>
#include <vector>
using namespace std;
#define ll long long
vector<int> adj[1000000];
ll DFS(int P[], int src, int par) {
ll ret = 0;
for (auto x : adj[src]) {
if (x != par) {
ret += DFS(P, x, src);
}
}
return P[src] + ret;
}
int LocateCentre(int N, int P[], int S[], int D[]) {
ll minCongestion = 2000000000;
int ans = -1;
for (int i = 0; i < N; i++) {
int s = S[i];
int d = D[i];
adj[s].push_back(d);
adj[d].push_back(s);
}
for (int i = 0; i < N; i++) {
ll congestionHere = 0;
for (auto c : adj[i]) {
congestionHere += DFS(P, c, i);
}
if (congestionHere < minCongestion) {
minCongestion = congestionHere;
ans = i;
}
}
return 3;
}
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... |