Submission #990283

#TimeUsernameProblemLanguageResultExecution timeMemory
990283starchanTowns (IOI15_towns)C++17
Compilation error
0 ms0 KiB
#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]+D)/2].pb(i); } int R = INF; for(auto [X, v]: diam) R = min(R, max(X, D-X)); vector<vector<int>> gd; for(auto [X, v]: diam) { if(max(X, D-X) == R) gd.pb(v); } return R; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:12:19: error: 'getDistance' was not declared in this scope; did you mean 'hubDistance'?
   12 |   opt = max(opt, {getDistance(i, 0), i});
      |                   ^~~~~~~~~~~
      |                   hubDistance
towns.cpp:12:40: error: no matching function for call to 'max(std::array<int, 2>&, <brace-enclosed initializer list>)'
   12 |   opt = max(opt, {getDistance(i, 0), i});
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from towns.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = std::array<int, 2>]'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:36: note:   no known conversion for argument 2 from '<brace-enclosed initializer list>' to 'const std::array<int, 2>&'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |                         ~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
towns.cpp:12:40: note:   candidate expects 3 arguments, 2 provided
   12 |   opt = max(opt, {getDistance(i, 0), i});
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from towns.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
towns.cpp:12:40: note:   'std::array<int, 2>' is not derived from 'std::initializer_list<_Tp>'
   12 |   opt = max(opt, {getDistance(i, 0), i});
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from towns.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
towns.cpp:12:40: note:   'std::array<int, 2>' is not derived from 'std::initializer_list<_Tp>'
   12 |   opt = max(opt, {getDistance(i, 0), i});
      |                                        ^
towns.cpp:18:27: error: 'getDistance' was not declared in this scope; did you mean 'hubDistance'?
   18 |   opt = max(opt, {d1[i] = getDistance(i, a), i});
      |                           ^~~~~~~~~~~
      |                           hubDistance
towns.cpp:18:48: error: no matching function for call to 'max(std::array<int, 2>&, <brace-enclosed initializer list>)'
   18 |   opt = max(opt, {d1[i] = getDistance(i, a), i});
      |                                                ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from towns.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = std::array<int, 2>]'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:36: note:   no known conversion for argument 2 from '<brace-enclosed initializer list>' to 'const std::array<int, 2>&'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |                         ~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
towns.cpp:18:48: note:   candidate expects 3 arguments, 2 provided
   18 |   opt = max(opt, {d1[i] = getDistance(i, a), i});
      |                                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from towns.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
towns.cpp:18:48: note:   'std::array<int, 2>' is not derived from 'std::initializer_list<_Tp>'
   18 |   opt = max(opt, {d1[i] = getDistance(i, a), i});
      |                                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from towns.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
towns.cpp:18:48: note:   'std::array<int, 2>' is not derived from 'std::initializer_list<_Tp>'
   18 |   opt = max(opt, {d1[i] = getDistance(i, a), i});
      |                                                ^
towns.cpp:26:11: error: 'getDistance' was not declared in this scope; did you mean 'hubDistance'?
   26 |   d2[i] = getDistance(i, b);
      |           ^~~~~~~~~~~
      |           hubDistance
towns.cpp:29:10: error: 'INF' was not declared in this scope
   29 |  int R = INF;
      |          ^~~
towns.cpp:8:28: warning: unused parameter 'sub' [-Wunused-parameter]
    8 | int hubDistance(int n, int sub)
      |                        ~~~~^~~