# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
399927 | bigg | Towns (IOI15_towns) | C++14 | 20 ms | 1084 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 = 110;
int dist[5][MAXN];
pair<int, int> p1, p2;
int hubDistance(int N, int sub) {
for(int i = 1; i < N; i++){
int d = getDistance(0, i);
if(d > p1.second) p1 = {i,d};
}
for(int i = 0; i < N; i++){
if(i == p1.first) continue;
dist[0][i] = getDistance(i, p1.first);
if(dist[0][i] > p2.second) p2 = {dist[0][i], i};
}
for(int i = 0; i < N; i++){
if(i == p2.first) continue;
dist[1][i] = getDistance(i, p2.first);
}
int ans = 1e9 + 10;
int diam = p2.second;
for(int i = 0; i < N; i++) ans = min(ans, (diam + abs(dist[0][i] - dist[1][i]))/2);
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... |