# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422773 | vanic | Towns (IOI15_towns) | C++14 | 20 ms | 396 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 <algorithm>
#include <iostream>
using namespace std;
const int maxn=120;
int dist[maxn][maxn];
int hubDistance(int n, int sub) {
int ind=0;
int maksi=0;
for(int i=1; i<n; i++){
dist[0][i]=dist[i][0]=getDistance(0, i);
if(maksi<dist[0][i]){
maksi=dist[0][i];
ind=i;
}
}
int ind1=0;
maksi=0;
for(int i=0; i<n; i++){
if(ind==i){
continue;
}
if(!dist[i][ind]){
dist[i][ind]=dist[ind][i]=getDistance(ind, i);
}
if(dist[i][ind]>maksi){
maksi=dist[i][ind];
ind1=i;
}
}
swap(ind, ind1);
for(int i=0; i<n; i++){
if(ind==i){
continue;
}
if(!dist[i][ind]){
dist[i][ind]=dist[ind][i]=getDistance(ind, i);
}
}
// cout << ind << ' ' << ind1 << endl;
// cout << maksi << endl;
int mini=1e9;
int br;
for(int i=0; i<n; i++){
if(i==ind || i==ind1){
continue;
}
// cout << i << ' ' << dist[i][ind] << ' ' << dist[i][ind1] << endl;
br=(dist[i][ind]+dist[i][ind1]-maksi)/2;
br=max(dist[i][ind], dist[i][ind1])-br;
// cout << br << endl;
mini=min(mini, br);
}
return mini;
}
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... |