# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1122692 | gustavo_d | Towns (IOI15_towns) | C++17 | 199 ms | 512 KiB |
#include "towns.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 111;
int cache[MAXN][MAXN];
int dist(int a, int b) {
if (a > b) swap(a, b);
if (a == b) return 0;
if (cache[a][b] != -1) return cache[a][b];
return cache[a][b] = getDistance(a, b);
}
int hubDistance(int n, int sub) {
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) cache[i][j] = -1;
}
int r = 1e9;
if (sub == 1 or true) {
for (int i=0; i<n; i++) {
for (int j=i+1; j<n; j++) {
// cerr << endl << endl;
// cerr << "Olhando: " << i << ' ' << j << endl;
map<pair<int, int>, int> mx_dist;
for (int k=0; k<n; k++) {
if (k == i or k == j) continue;
int a = (dist(i, k) + dist(j, k) - dist(i, j)) / 2;
int x = dist(i, k) - a;
int y = dist(j, k) - a;
mx_dist[{x, y}] = max({mx_dist[{x, y}], a, x, y});
# | 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... |