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;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MX = 120;
static int mem[MX][MX];
int n;
int getD(int u, int v) {
if(mem[u][v] != -1)
return mem[u][v];
return mem[u][v] = mem[v][u] = getDistance(u,v);
}
int hubDistance(int N, int sub) {
n = N;
RE(i,n) RE(j,n) mem[i][j] = -1;
RE(i,n) mem[i][i] = 0;
int u = 0, v=0;
RE(i,n)
if(getD(u,i) > getD(u,v))
v = i;
RE(i,n)
if(getD(v,i) > getD(u,v))
u = i;
int res = getD(u,v);
RE(i,n) {
if(i == u || i == v) continue;
int nres = getD(u,i) + getD(v,i) - getD(u,v);
nres /= 2;
nres = getD(u,i) - nres;
nres = max(nres, getD(u,v)-nres);
res = min(res, nres);
}
return res;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:44:28: warning: unused parameter 'sub' [-Wunused-parameter]
44 | 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... |