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"
#ifndef EVAL
#include "grader.cpp"
#endif // EVAL
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
int dist[1000],distv[1000],distu[1000];
int hubDistance(int N, int sub) {
int i,mx=0,j,v,u,len=2e9+7;
for( i=0;i<N;++i){
dist[i] = getDistance(0,i);
if (dist[i] > mx){
mx = dist[i];
v = i;
}
}
mx = 0;
for (i=1;i<N;++i){
if (i == v)continue;
distv[i] = getDistance(v,i);
if (mx > distv[i]){
mx = distv[i];
u = i;
}
}
mx = 0;
for (i=1;i<N;++i){
if (i == v || i == u)continue;
distu[i] = getDistance(v,i);
}
{
int a = (dist[v]+distv[u]-dist[u])/2;
int b = (dist[v]+dist[u]-distv[u])/2;
int c = (dist[v]+distv[u]-dist[v])/2;
len = max(max(a,b),c);
}
for (i=1;i<N;++i){
if (i == v || i == u)continue;
int a = (distv[i]+distu[i]-distv[u])/2;
int b = (distv[i]+distv[u]-distu[i])/2;
int c = (distu[i]+distv[i]-distv[i])/2;
a = max(max(a,b),c);
len = min(len,a);
}
ret len;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:29:13: warning: unused variable 'j' [-Wunused-variable]
29 | int i,mx=0,j,v,u,len=2e9+7;
| ^
towns.cpp:28:28: warning: unused parameter 'sub' [-Wunused-parameter]
28 | int hubDistance(int N, int sub) {
| ~~~~^~~
towns.cpp:52:30: warning: 'u' may be used uninitialized in this function [-Wmaybe-uninitialized]
52 | int a = (dist[v]+distv[u]-dist[u])/2;
| ~~~~~~~^
towns.cpp:52:21: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
52 | int a = (dist[v]+distv[u]-dist[u])/2;
| ~~~~~~^
# | 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... |