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<bits/stdc++.h>
#include "towns.h"
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,fx[124][124],A,B,pas;
int getdis(int q, int w){
if(q==w) return 0;
if(fx[q][w]==0){
fx[q][w]=fx[w][q]=getDistance(q-1,w-1);
}
return fx[q][w];
}
int hubDistance(int NN, int sub) {
a=NN;
for(i=0; i<=a+1; i++){
for(j=0; j<=a+1; j++){
fx[i][j]=0;
}
}
zx=0;xc=i;
for(i=1; i<=a; i++){
if(i==1) continue;
c=getdis(1,i);
if(zx<c){
zx=c;xc=i;
}
}
A=xc;zx=0;xc=A;
for(i=1; i<=a; i++){
if(i==A) continue;
c=getdis(A,i);
if(zx<c){
zx=c;xc=i;
}
}
B=xc;
for(i=1; i<=a; i++){
if(B==i) continue;
getdis(B,i);
}
pas=fx[A][B];
for(i=1; i<=a; i++){
if(i==A||i==B) continue;
c=fx[A][i];d=fx[i][B];e=fx[A][B];
e=(c+d-e)/2;zx=c-e;xc=d-e;
pas=min(pas,max(zx,xc));
}
return pas;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:12:29: warning: unused parameter 'sub' [-Wunused-parameter]
12 | int hubDistance(int NN, 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... |