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 <algorithm>
int d[111][111];
int getDist(int i,int j)
{
if(i==j)return 0;
if(i>j)std::swap(i,j);
if(!d[i][j])d[i][j]=getDistance(i,j);
return d[i][j];
}
int hubDistance(int n, int s)
{
int m1,m2;
int i;
for(i=m1=0;i<n;i++)if(getDist(0,i)>getDist(0,m1))m1=i;
for(i=m2=0;i<n;i++)if(getDist(m1,i)>getDist(m1,m2))m2=i;
return(getDist(0,m1)+getDist(m1,m2)-getDist(0,m2))/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... |