# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494640 | thecodingwizard | Towns (IOI15_towns) | C++11 | 13 ms | 844 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 <bits/stdc++.h>
#include "towns.h"
using namespace std;
int hubDistance(int N, int sub) {
int maxDist = -1, maxDistNode = -1;
for (int i = 1; i < N; i++) {
int d = getDistance(0, i);
if (d > maxDist) {
maxDist = d;
maxDistNode = i;
}
}
maxDist = -1;
int maxDistNode2 = -1;
for (int i = 0; i < N; i++) {
int d = getDistance(maxDistNode, i);
if (d > maxDist) {
maxDist = d;
maxDistNode2 = i;
}
}
int opt = 1e9;
for (int i = 0; i < N; i++) {
int distTo0 = getDistance(maxDistNode2, i);
int distTo1 = getDistance(maxDistNode, i);
int dist0 = (maxDist + distTo0 - distTo1)/2;
int dist1 = (maxDist + distTo1 - distTo0)/2;
opt = min(opt, max(dist0, dist1));
}
return opt;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |