# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
990282 |
2024-05-30T06:08:31 Z |
starchan |
Towns (IOI15_towns) |
C++17 |
|
0 ms |
0 KB |
#include<bits/stdc++.h>
#include "towns.h"
using namespace std;
#define in array<int, 2>
#define pb push_back
#define pob pop_back
int hubDistance(int n, int sub)
{
in opt = {0, 0};
for(int i = 1; i < n; i++)
opt = max(opt, {getDistance(i, 0), i});
int a = opt[1]; opt = {0, a};
vector<int> d1(n), d2(n); d1[a] = 0;
for(int i = 0; i < n; i++)
{
if(i == a) continue;
opt = max(opt, {d1[i] = getDistance(i, a), i});
}
auto [D, b] = opt; d2[b] = 0;
map<int, vector<int>> diam; diam[0].pb(a); diam[D].pb(b);
for(int i = 0; i < n; i++)
{
if(i == a || i == b)
continue;
d2[i] = getDistance(i, b);
diam[(d1[i]-d2[i]+C)/2].pb(i);
}
int R = INF;
for(auto [X, v]: diam)
R = min(R, max(X, C-X));
vector<vector<int>> gd;
for(auto [X, v]: diam)
{
if(max(X, C-X) == R)
gd.pb(v);
}
return R;
}
Compilation message
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:27:21: error: 'C' was not declared in this scope
27 | diam[(d1[i]-d2[i]+C)/2].pb(i);
| ^
towns.cpp:29:10: error: 'INF' was not declared in this scope
29 | int R = INF;
| ^~~
towns.cpp:31:21: error: 'C' was not declared in this scope
31 | R = min(R, max(X, C-X));
| ^
towns.cpp:35:13: error: 'C' was not declared in this scope
35 | if(max(X, C-X) == R)
| ^
towns.cpp:8:28: warning: unused parameter 'sub' [-Wunused-parameter]
8 | int hubDistance(int n, int sub)
| ~~~~^~~