# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
795409 | Josia | Towns (IOI15_towns) | C++17 | 13 ms | 484 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 hubDistance(int N, int sub) {
int d1=0, v1 = 0;
for (int i = 1; i<N; i++) {
int d = getDistance(0, i);
if (d>d1) {
d1 = d;
v1 = i;
}
}
vector<int> dists1(N);
int d2=0, v2=v1;
for (int i = 0; i<N; i++) {
int d = getDistance(v1, i);
dists1[i] = d;
if (d>d2) {
d2 = d;
v2 = i;
}
}
vector<int> dists2(N);
for (int i = 0; i<N; i++) {
int d = getDistance(v2, i);
dists2[i] = d;
}
int R = 1e9;
for (int i = 0; i<N; i++) {
int rem = (dists1[i]+dists2[i]-d2)/2;
R = min(R, max(dists1[i]-rem, dists2[i]-rem));
}
return R;
}
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... |