# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1088386 | Pacybwoah | Towns (IOI15_towns) | C++17 | 11 ms | 960 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<vector>
#include<algorithm>
#include<utility>
using namespace std;
int hubDistance(int N, int sub) {
int a = -1, b = -1;
int maxi = 0, n = N;
for(int i = 1; i < n; i++){
int len = getDistance(0, i);
if(len > maxi){
maxi = len;
a = i;
}
}
vector<int> dista(n), distb(n);
maxi = 0;
for(int i = 0; i < n; i++){
dista[i] = getDistance(a, i);
if(dista[i] > maxi){
maxi = dista[i];
b = i;
}
}
for(int i = 0; i < n; i++){
distb[i] = getDistance(b, i);
}
int d = dista[b];
int ans = 1e9;
for(int i = 0; i < n; i++){
int da = (d + dista[i] + distb[i]) / 2 - distb[i], db = (d + dista[i] + distb[i]) / 2 - dista[i];
ans = min(ans, max(da, db));
}
return ans;
}
// g++ -std=c++17 -Wall -Wextra -fsanitize=undefined -fsanitize=address -Wshadow -o run towns.cpp grader.cpp
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... |