# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
590917 | yutabi | Towns (IOI15_towns) | C++14 | 22 ms | 468 KiB |
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;
int hubDistance(int N, int sub)
{
int R=1000000007;
int best=0;
int d1=0;
int d2=0;
int d1_dist[200];
int d2_dist[200];
for(int i=1;i<N;i++)
{
int res=getDistance(0,i);
if(res>best)
{
best=res;
d1=i;
}
}
d1_dist[0]=best;
for(int i=1;i<N;i++)
{
if(i!=d1)
{
int res=getDistance(d1,i);
if(res>best)
{
best=res;
d2=i;
}
d1_dist[i]=res;
}
}
d2_dist[d1]=best;
for(int i=0;i<N;i++)
{
if(i!=d1 && i!=d2)
{
d2_dist[i]=getDistance(d2,i);
}
}
for(int i=0;i<N;i++)
{
if(i!=d1 && i!=d2)
{
int sum=(d1_dist[i]+d2_dist[i]-d1_dist[d2])/2;
R=min(R,max(d1_dist[i]-sum,d2_dist[i]-sum));
}
}
return R;
}
Compilation message (stderr)
# | 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... |