# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
748248 | Abrar_Al_Samit | Towns (IOI15_towns) | C++17 | 16 ms | 1104 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;
const int nax = 110;
int from0[nax];
int from_en[2][nax];
int en1, en2;
int hubDistance(int N, int sub) {
int mx = 0;
for(int i=1; i<N; ++i) {
from0[i] = getDistance(0, i);
if(mx<from0[i]) {
mx = from0[i];
en1 = i;
}
}
mx = 0;
for(int i=0; i<N; ++i) {
from_en[0][i] = getDistance(i, en1);
if(from_en[0][i]>mx) {
mx = from_en[0][i];
en2 = i;
}
}
for(int i=0; i<N; ++i) {
from_en[1][i] = getDistance(i, en2);
}
int R = 2e9;
map<int, int>groups;
for(int i=0; i<N; ++i) {
int a_plus_b = from_en[0][en2];
int a_plus_c = from_en[0][i];
int b_plus_c = from_en[1][i];
int b = (b_plus_c - a_plus_c + a_plus_b) / 2;
int c = b_plus_c - b;
int a = a_plus_b - b;
R = min(R, max(a, b));
groups[b]++;
}
for(auto it : groups) if(it.second>N/2) {
R = -R;
break;
}
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... |