# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
140585 | SirCeness | Towns (IOI15_towns) | C++14 | 21 ms | 1016 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>
#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define orta ((l+r)>>1)
#define INF 1000000009
#define mod 1000000007
#define ppair(x) "(" << x.first << ", " << x.second << ") "
#define bas(x) #x << ": " << x << " "
#define prarr(x, n); cerr << #x << ": "; for(int qsd = 0; qsd < n; qsd++) cerr << x[qsd] << " "; cerr << "\n";
#define prarrv(x); cerr << #x << ": "; for(int qsd = 0; qsd < (int)x.size(); qsd++) cerr << x[qsd] << " "; cerr << "\n";
using namespace std;
typedef long long ll;
int n;
int getmaxdist(int node){
int ans = node;
int dist = 0;
for (int i = 0; i < n; i++){
if (i == node) continue;
int res = getDistance(node, i);
if (res > dist){
dist = res;
ans = i;
}
}
return ans;
}
int hubDistance(int N, int sub) {
n = N;
int node1 = getmaxdist(0);
int node2 = getmaxdist(node1);
int r = 100000000;
int dist = getDistance(node1, node2);
//cout << bas(node1) << bas(node2) << bas(dist) << endl;
for (int i = 0; i < n; i++){
if (i == node1 || i == node2) continue;
int d1 = getDistance(i, node1);
int d2 = getDistance(i, node2);
int uzak = (d1+d2-dist)/2;
int uzak1 = d1-uzak;
int uzak2 = d2-uzak;
//cout << bas(i) << bas(uzak1) << bas(uzak2) << bas(uzak) << endl;
int rtmp = max(max(uzak, uzak1), uzak2);
r = min(r, rtmp);
}
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... |