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;
using ll = int;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
const ll MAXN = 120;
ll dist[3][MAXN];
ll n;
ll get_dist(ll u,ll d[]){
ll res = 0;
for (ll i = 0;i < n;i ++){
if (i == u){
d[u] = 0;
}
else{
d[i] = getDistance(i,u);
if (d[res] < d[i])res = i;
}
}
return res;
}
int hubDistance(int N, int sub) {
n=N;
ll a = get_dist(0,dist[0]);
ll b = get_dist(a,dist[1]);
get_dist(b,dist[2]);
ll res = 1e9;
for (ll i = 0;i < n;i ++){
ll ab,ac,bc,abc;
ab = dist[1][b];
ac = dist[1][i];
bc = dist[2][i];
abc = (ab+ac+bc)/2;
res = min(res,max(abc-bc,abc-ac));
}
// cout<<a<<' '<<b<<'\n';
return res;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:29:28: warning: unused parameter 'sub' [-Wunused-parameter]
29 | 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... |