# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
615493 | Apiram | Towns (IOI15_towns) | C++14 | 17 ms | 1088 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 root = 0;
vector<int>dist(N);
for (int i = 0;i<N;++i){
if (i == root)dist[i] = 0;
else dist[i] = getDistance(i,root);
}
for (int i = 0;i<N;++i){
if (dist[i] > dist[root]){
root = i;
}
}
for (int i = 0;i<N;++i){
if (i == root)dist[i] = 0;
else dist[i] = getDistance(i,root);
}
int root2 = root;
for (int i = 0;i<N;++i){
if (dist[i] > dist[root2])root2 = i;
}
int maxxy = dist[root2];
vector<int>dist2(N);
for (int i = 0;i<N;++i){
if (i == root2){
dist2[i] = 0;
}
else{
dist2[i] = getDistance(root2,i);
}
}
int answer = INT_MAX;
for (int i = 0;i<N;++i){
if (dist[i] + dist2[i] == maxxy){
answer = min(answer,max(dist[i],dist2[i]));
}
}
return answer;
}
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... |