# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1014724 | MarwenElarbi | Towns (IOI15_towns) | C++17 | 14 ms | 1112 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 <bits/stdc++.h>
#include "towns.h"
using namespace std;
int getDistance(int i, int j);
int hubDistance(int N, int sub) {
long long mx=0;
int one;
for (int i = 1; i < N; ++i)
{
long long cur=getDistance(0,i);
if(cur>mx){
mx=cur;
one=i;
}
}
vector<long long> a(N,0);
int two;
mx=0;
for (int i = 0; i < N; ++i)
{
if(i==one) continue;
a[i]=getDistance(one,i);
if(a[i]>mx){
mx=a[i];
two=i;
}
}
vector<long long> b(N,0);
for (int i = 0; i < N; ++i)
{
if(i==two) continue;
b[i]=getDistance(two,i);
}
long long d=a[two];
long long res=1e18;
for (int i = 0; i < N; ++i)
{
if(i==one||i==two) continue;
long long x=abs(a[i]-b[i]);
long long r=0;
r=max(r,(x+d)/2);
r=max(r,d-(d+x)/2);
res=min(res,r);
}
return res;
}
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... |