# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
399689 | peuch | Towns (IOI15_towns) | C++17 | 26 ms | 1116 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;
const int MAXN = 1e6;
int dist[3][MAXN];
int hubDistance(int N, int sub) {
int p1 = 0, p2 = 0;
int maxi = 0;
for(int i = 0; i < N; i++){
int aux = getDistance(0, i);
if(aux > maxi) p1 = i, maxi = aux;
}
maxi = 0;
for(int i = 0; i < N; i++){
dist[0][i] = getDistance(p1, i);
if(dist[0][i] > maxi) maxi = dist[0][i], p2 = i;
}
for(int i = 0; i < N; i++)
dist[1][i] = getDistance(p2, i);
int diam = dist[0][p2];
int ans = MAXN;
for(int i = 0; i < N; i++){
int x = (diam + dist[0][i] - dist[1][i]) / 2;
ans = min(ans, max(x, diam - x));
}
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... |