# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
718922 | Karuk | Towns (IOI15_towns) | C++14 | 12 ms | 852 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;
long long getD(int x,int y) {
return getDistance(x,y);
}
long long getmindist(int f,int s,int t) {
long long d1=getD(f,s);
long long d2=getD(s,t);
long long d3=getD(f,t);
long long dd=(d1+d2-d3)/2;
long long d=(d1+d3-d2)/2;
long long ddd=(d2+d3-d1)/2;
return min(min(d,dd),ddd);
}
int hubDistance(int n,int sub) {
int maxd=0,maxind=0;
int md=0;
for(int i=1;i<n;i++) {
int p=getD(0,i);
if(maxd<p) {
maxd=p;
maxind=i;
}
}
md=maxind;
maxd=0;
maxind=0;
for(int i=1;i<n;i++) {
int p=getD(md,i);
if(maxd<p) {
maxd=p;
maxind=i;
}
}
long long minr=1e12;
for(int i=0;i<n;i++) {
if(i==md || i==maxind)continue;
minr=min(minr,getmindist(i,md,maxind));
}
return minr;
}
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... |