# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433339 | timmyfeng | Towns (IOI15_towns) | C++17 | 25 ms | 952 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>
using namespace std;
#include "towns.h"
const int N = 110;
int dist_0[N], dist_u[N], pos[N];
int hubDistance(int n, int subtask) {
for (int i = 1; i < n; ++i) {
dist_0[i] = getDistance(0, i);
}
int u = max_element(dist_0, dist_0 + n) - dist_0;
dist_u[0] = dist_0[u];
for (int i = 1; i < n; ++i) {
dist_u[i] = u == i ? 0 : getDistance(u, i);
}
int v = max_element(dist_u, dist_u + n) - dist_u;
pos[0] = (dist_0[u] - dist_0[v] + dist_u[v]) / 2;
for (int i = 1; i < n; ++i) {
pos[i] = min(pos[0], (dist_0[u] - dist_0[i] + dist_u[i]) / 2);
}
int ans = INT_MAX;
for (int i = 0; i < n; ++i) {
ans = min(ans, max(pos[i], dist_u[v] - pos[i]));
}
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... |