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;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ms memset
#define pb push_back
#define fi first
#define se second
#define dist(i,j) getDistance(i,j)
int hubDistance(int N, int sub) {
int d[N][N]; ms(d,0,sizeof(d));
int mx = 0, u=0;
FOR(i,1,N){
d[0][i] = d[i][0] = dist(0,i);
if (d[0][i] > mx){
mx=d[0][i]; u=i;
}
}
mx=0; int v = 0;
FOR(i,0,N){
if (i==u) continue;
if (i>0) d[u][i]=d[i][u]=dist(i,u);
if (d[u][i]>mx){
v=i; mx=d[u][i];
}
}
FOR(i,0,N){
if (i==u || i==v) continue;
d[i][v]=d[v][i]=dist(i,v);
}
int R=2e9;
FOR(i,0,N){
R=min(R,abs(d[u][i]-d[v][i])+d[u][v]);
}
R/=2;
return R;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:19:28: warning: unused parameter 'sub' [-Wunused-parameter]
19 | 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... |