# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
587541 | benson1029 | Towns (IOI15_towns) | C++14 | 21 ms | 852 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<bits/stdc++.h>
using namespace std;
int dis0[200], disX[200], disY[200];
int hubDistance(int N, int sub) {
int X = 1;
for(int i=1; i<N; i++) {
dis0[i] = getDistance(0, i);
if(dis0[i] > dis0[X]) {
X = i;
}
}
int Y = 0;
for(int i=0; i<N; i++) {
if(i==X) continue;
disX[i] = getDistance(X, i);
if(disX[i] > disX[Y]) {
Y = i;
}
}
// diameter: X to Y
for(int i=0; i<N; i++) {
if(i==Y) continue;
disY[i] = getDistance(Y, i);
}
int ans = 1e9;
for(int i=0; i<N; i++) {
if(i==X || i==Y) continue;
int sum = (disX[Y] + disX[i] + disY[i]) / 2;
int tmp = max(sum - disX[i], sum - disY[i]);
if(tmp < ans) ans = tmp;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |