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"
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
array<int,3> solve(int ab,int ac,int bc){
int abc = (ab+ac+bc)/2;
int a = abc - bc;
int b = abc - ac;
int c = abc - ab;
return {a,b,c};
}
int hubDistance(int N, int sub){
int dia1 = 0 , cur = 0;
for(int i = 0; i < N ;i++){
int u = getDistance(0, i);
if(u > cur){
dia1 = i;
cur = u;
}
}
int dia2 = dia1; cur = 0;
vector<int> uz1(N,0),uz2(N,0);
for(int i = 0; i < N ; i++){
int u = getDistance(dia1, i);
uz1[i] = u;
if(u > cur){
dia2 = i;
cur = u;
}
}
int res = 0;
for(int i = 0; i < N; i++) uz2[i] = getDistance(dia2,i);
for(int i = 0; i < N; i++){
auto x = solve(cur,uz1[i],uz2[i]);
res=max({res,x[0],x[1]});
}
return res;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:15:28: warning: unused parameter 'sub' [-Wunused-parameter]
15 | int hubDistance(int N, int sub){
| ~~~~^~~
# | 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... |