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;
#define REP(i,n) for(int i = 0; i < n; i ++)
#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define vi vector<int>
#define pb push_back
int d0[1005],dA[1005];
int n,A,B;
int hubDistance(int N, int sub){
n = N;
A = B = 0;
d0[0] = 0;
FOR(i,1,n){
d0[i] = getDistance(0,i);
if(d0[i] > d0[A]) A = i;
}
dA[0] = d0[A];
dA[A] = 0;
FOR(i,1,n){
if(i == A) continue;
dA[i] = getDistance(A,i);
if(dA[i] > dA[B]) B = i;
}
int R = 1000000000;
vi gg; // dist from A from path A-0
REP(i,n){
int lol = (dA[0]+dA[i]-d0[i])/2;
gg.pb(lol);
R = min(R,max(dA[B]-lol,lol));
}
return R;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:13:28: warning: unused parameter 'sub' [-Wunused-parameter]
13 | 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... |