# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167465 | faremy | Towns (IOI15_towns) | C++14 | 27 ms | 1172 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 "towns.h"
#include <algorithm>
#include <iostream>
const int MAXN = 110;
int distToEnd[MAXN];
int hubDistance(int N, int sub)
{
int farthest = 0, end = 0;
for (int iNode = 0; iNode < N; iNode++)
{
int dist = getDistance(0, iNode);
if (dist > farthest)
{
farthest = dist;
end = iNode;
}
}
int diameter = 0, otherEnd = end;
for (int iNode = 0; iNode < N; iNode++)
{
distToEnd[iNode] = getDistance(end, iNode);
if (distToEnd[iNode] > diameter)
{
diameter = distToEnd[iNode];
otherEnd = iNode;
}
}
int minMaxDist = diameter;
for (int iNode = 0; iNode < N; iNode++)
{
int distToOth = getDistance(iNode, otherEnd);
int half = (diameter + distToEnd[iNode] - distToOth) / 2;
minMaxDist = std::min(minMaxDist, std::max(half, diameter - half));
}
return minMaxDist;
}
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... |