# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
349811 | pit4h | Towns (IOI15_towns) | C++14 | 23 ms | 364 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>
#include "towns.h"
using namespace std;
const int MAXN = 111;
int dist[MAXN][MAXN];
int n, subtask;
int hubDistance(int N, int sub) {
int l = -1, r = -1;
subtask = sub;
n = N;
for(int i=1; i<n; ++i) {
dist[0][i] = getDistance(0, i);
dist[i][0] = dist[0][i];
if(l==-1 || dist[0][i] > dist[0][l]) {
l = i;
}
}
for(int i=0; i<n; ++i) {
if(i==l) continue;
dist[l][i] = getDistance(l, i);
dist[i][l] = dist[l][i];
if(r==-1 || dist[l][i] > dist[l][r]) {
r = i;
}
}
int R = 1e9+1;
vector<int> candidates;
for(int i=0; i<n; ++i) {
if(i==l || i==r) continue;
//dist[r][i] = getDistance(r, i);
//dist[i][r] = dist[r][i];
int tmp = (dist[l][i] + dist[0][i] - dist[0][l])/2;
int dl = dist[l][i] - tmp, d0 = dist[0][i] - tmp;
int dd = dist[l][r] - (dist[0][r] + dist[l][r] - dist[0][l])/2;
if(dl <= dd) {
int rc = max(dl, dist[l][r] - dl);
R = min(R, rc);
}
}
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... |