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 PB push_back
#define F first
#define S second
int hubDistance(int N, int sub) {
int n=N;
pair<int,int> maxdis={-1,-1};
for(int i=0;i<n;i++){
int x=getDistance(0,i);
if(x>maxdis.F)maxdis={x,i};
}
int a=maxdis.S;
maxdis={-1,-1};
for(int i=0;i<n;i++){
int x=getDistance(a,i);
if(x>maxdis.F)maxdis={x,i};
}
int b=maxdis.S;
int dia=maxdis.F;
int ans=dia;
for(int i=0;i<n;i++){
int itoa=getDistance(i,a),itob=getDistance(i,b);
int itodia=(itoa+itob-dia)/2;
ans=min(ans,max(itoa-itodia,itob-itodia));
}
return ans;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:8:28: warning: unused parameter 'sub' [-Wunused-parameter]
8 | 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... |