# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
599360 | Temmie | Towns (IOI15_towns) | C++17 | 16 ms | 348 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>
int hubDistance(int n, int sub) {
int l1, l2;
int mx = 0;
for (int i = 1; i < n; i++) {
int val = getDistance(0, i);
if (val > mx) {
mx = val;
l1 = i;
}
}
std::vector <int> dl1(n, -1);
std::vector <int> dl2(n, -1);
mx = 0;
for (int i = 0; i < n; i++) {
if (i == l1) {
continue;
}
dl1[i] = getDistance(l1, i);
if (dl1[i] > mx) {
mx = dl1[i];
l2 = i;
}
}
for (int i = 0; i < n; i++) {
if (i == l2) {
continue;
}
dl2[i] = getDistance(l2, i);
}
int r = 1 << 30;
for (int i = 0; i < n; i++) {
if (i == l1 || i == l2) {
continue;
}
//int to = (dl1[i] + dl2[i] - dl1[l2]) / 2;
int x = (dl1[l2] + dl1[i] - dl2[i]) / 2;
int y = (dl2[l1] + dl2[i] - dl1[i]) / 2;
r = std::min(r, std::max(x, y));
}
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... |