Submission #310412

#TimeUsernameProblemLanguageResultExecution timeMemory
310412aZvezdaTowns (IOI15_towns)C++14
Compilation error
0 ms0 KiB
#ifndef towns_h #define towns_h int getDistance(int i, int j); int hubDistance(int N, int sub); #include <bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #define endl "\n" typedef long long ll; template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { out << x.first << " " << x.second; return out;} template<class T, class T2> inline istream &operator >>(istream &in, pair<T, T2> &x) { in >> x.first >> x.second; return in;} template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; } const ll mod = 1e9 + 7; #define out(x) "{" << (#x) << ": " << x << "} " const int MAX_N = 115; int dist0[MAX_N], dist1[MAX_N]; map<int, vector<int> > comp; int hubDistance(int N, int sub) { int first = 0; for(int i = 1; i < N; i ++) { dist0[i] = getDistance(0, i); if(dist0[i] > dist0[first]) { first = i; } } int R = mod; int second = 0; for(int i = 0; i < N; i ++) { dist1[i] = getDistance(first, i); if(dist1[i] > dist1[second]) { second = i; } vector<int> hubs; for(int i = 0; i < N; i ++) { int now = dist0[i] + dist1[i] - dist1[0]; now /= 2; now = dist1[i] - now; cost[i] = now; where[now].first.push_back(i); chkmin(R, max({now, dist1[second] - now})); } int toLft = 0, toRght = N; bool centroid = false; for(auto it : where) { auto arr = it.second; toRght -= arr.size(); if(max(cost[it.first], dist1[second] - cost[it.first]) == R && toLft <= n / 2 && toRght <= n / 2) { } toLft += arr.size(); } if(!centroid) { return -R; } else { return R; } } #endif

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:40:13: warning: declaration of 'i' shadows a previous local [-Wshadow]
   40 |     for(int i = 0; i < N; i ++) {
      |             ^
towns.cpp:34:13: note: shadowed declaration is here
   34 |     for(int i = 0; i < N; i ++) {
      |             ^
towns.cpp:42:9: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   42 |         cost[i] = now;
      |         ^~~~
      |         cosl
towns.cpp:43:9: error: 'where' was not declared in this scope
   43 |         where[now].first.push_back(i);
      |         ^~~~~
towns.cpp:48:19: error: 'where' was not declared in this scope
   48 |     for(auto it : where) {
      |                   ^~~~~
towns.cpp:51:16: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   51 |         if(max(cost[it.first], dist1[second] - cost[it.first]) == R && toLft <= n / 2 && toRght <= n / 2) {
      |                ^~~~
      |                cosl
towns.cpp:51:81: error: 'n' was not declared in this scope
   51 |         if(max(cost[it.first], dist1[second] - cost[it.first]) == R && toLft <= n / 2 && toRght <= n / 2) {
      |                                                                                 ^
towns.cpp:61:1: error: expected '}' at end of input
   61 | }
      | ^
towns.cpp:24:33: note: to match this '{'
   24 | int hubDistance(int N, int sub) {
      |                                 ^
towns.cpp:24:28: warning: unused parameter 'sub' [-Wunused-parameter]
   24 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
towns.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
   61 | }
      | ^