Submission #843661

#TimeUsernameProblemLanguageResultExecution timeMemory
843661BoasClosing Time (IOI23_closing)C++17
Compilation error
0 ms0 KiB
#include "closing.h" using namespace std; #include <bits/stdc++.h> typedef long long ll; typedef vector<ll> vi; typedef vector<vi> vvi; typedef vector<bool> vb; typedef pair<ll, ll> ii; typedef vector<ii> vii; typedef vector<vii> vvii; typedef set<ii> sii; typedef vector<sii> vsii; typedef tuple<ll, ll, ll, bool> item; #define ALL(x) (x).begin(), x.end() #define loop(x, i) for (int i = 0; i < x; i++) void getDist(int i, ll d, vi &dist, const vsii &adj) { dist[i] = d; for (auto [j, w] : adj[i]) { if (dist[j] != -1) continue; getDist(j, dist[i] + w, dist, adj); } } int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W) { vsii adj(N); loop(N - 1, i) { adj[U[i]].insert({V[i], W[i]}); adj[V[i]].insert({U[i], W[i]}); } vi distX(N, -1), distY(N, -1); distX[X] = 0; distY[Y] = 0; getDist(X, 0, distX, adj); getDist(Y, 0, distY, adj); int max = 0; // vb visX(N); // vb visY(N); for (int xleft = 0; X - xleft >= 0; xleft++) { for (int xright = 0; X + xright < N; xright++) { for (int yleft = 0; yleft <= Y; yleft++) { ll sum = 0; for (int i = 0; i < Y; i++) { int v = 0; if (X - xleft <= i && i <= X + xright) { v = std::max(v, distX[i]); } if (Y - yleft <= i) { v = std::max(v, distY[i]); } sum += v; } int yright = 0; for (; Y + yright < N; yright++) { int v = distY[Y + yright]; if (X + xright >= Y + yright) v = std::max(v, distX[Y + yright]); sum += v; if (K - sum < 0) break; int count = 2 + xright + yright + xleft + yleft; if (count > max) { cerr << "Solution has: " << xleft << ' ' << xright << ' ' << yleft << ' ' << yright << endl; max = count; } } } } } cerr << endl; return max; }

Compilation message (stderr)

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:57:49: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   57 |                         v = std::max(v, distX[i]);
      |                                                 ^
In file included from /usr/include/c++/10/vector:60,
                 from closing.h:1,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
closing.cpp:57:49: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   57 |                         v = std::max(v, distX[i]);
      |                                                 ^
In file included from /usr/include/c++/10/vector:60,
                 from closing.h:1,
                 from closing.cpp:1:
/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:
closing.cpp:57:49: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   57 |                         v = std::max(v, distX[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 closing.cpp:3:
/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:
closing.cpp:57:49: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |                         v = std::max(v, distX[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 closing.cpp:3:
/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:
closing.cpp:57:49: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |                         v = std::max(v, distX[i]);
      |                                                 ^
closing.cpp:61:49: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   61 |                         v = std::max(v, distY[i]);
      |                                                 ^
In file included from /usr/include/c++/10/vector:60,
                 from closing.h:1,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
closing.cpp:61:49: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   61 |                         v = std::max(v, distY[i]);
      |                                                 ^
In file included from /usr/include/c++/10/vector:60,
                 from closing.h:1,
                 from closing.cpp:1:
/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:
closing.cpp:61:49: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   61 |                         v = std::max(v, distY[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 closing.cpp:3:
/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:
closing.cpp:61:49: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   61 |                         v = std::max(v, distY[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 closing.cpp:3:
/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:
closing.cpp:61:49: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   61 |                         v = std::max(v, distY[i]);
      |                                                 ^
closing.cpp:70:58: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   70 |                         v = std::max(v, distX[Y + yright]);
      |                                                          ^
In file included from /usr/include/c++/10/vector:60,
                 from closing.h:1,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
closing.cpp:70:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   70 |                         v = std::max(v, distX[Y + yright]);
      |                                                          ^
In file included from /usr/include/c++/10/vector:60,
                 from closing.h:1,
                 from closing.cpp:1:
/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:
closing.cpp:70:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   70 |                         v = std::max(v, distX[Y + yright]);
      |                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from closing.cpp:3:
/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:
closing.cpp:70:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   70 |                         v = std::max(v, distX[Y + yright]);
      |                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from closing.cpp:3:
/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:
closing.cpp:70:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   70 |                         v = std::max(v, distX[Y + yright]);
      |                                                          ^