Submission #1253597

#TimeUsernameProblemLanguageResultExecution timeMemory
1253597antonnRotating Lines (APIO25_rotate)C++20
Compilation error
0 ms0 KiB
#include "rotate.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; template<typename T> bool assign_min(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<typename T> bool assign_max(T& a, T b) { if (a < b) { a = b; return true; } return false; } void energy(int n, vector<int> v) { vector<int> ord(n); iota(ord.begin(), ord.end(), 0); sort(ord.begin(), ord.end(), [&](int x, int y) { return v[x] < v[y]; }); int half = n / 2; vector<vector<int>> rot(20); for (int i = 0; i < half; i++) { int want = (v[ord[i]] + 25000) % 50000; int x = (want - v[ord[i + half]] + 50000) % 50000; rotate(ord[i + half], x); } }

Compilation message (stderr)

rotate.cpp: In function 'void energy(int, std::vector<int>)':
rotate.cpp:37:15: error: no matching function for call to 'rotate(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, int&)'
   37 |         rotate(ord[i + half], x);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:62,
                 from rotate.h:1,
                 from rotate.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:1405:5: note: candidate: 'template<class _FIter> constexpr _FIter std::_V2::rotate(_FIter, _FIter, _FIter)'
 1405 |     rotate(_ForwardIterator __first, _ForwardIterator __middle,
      |     ^~~~~~
/usr/include/c++/11/bits/stl_algo.h:1405:5: note:   template argument deduction/substitution failed:
rotate.cpp:37:15: note:   candidate expects 3 arguments, 2 provided
   37 |         rotate(ord[i + half], x);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from rotate.cpp:2:
/usr/include/c++/11/pstl/glue_algorithm_defs.h:260:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::rotate(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _ForwardIterator)'
  260 | rotate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last);
      | ^~~~~~
/usr/include/c++/11/pstl/glue_algorithm_defs.h:260:1: note:   template argument deduction/substitution failed:
rotate.cpp:37:15: note:   candidate expects 4 arguments, 2 provided
   37 |         rotate(ord[i + half], x);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~
In file included from rotate.cpp:1:
rotate.h:4:6: note: candidate: 'void rotate(std::vector<int>, int)'
    4 | void rotate(std::vector<int> t, int x);
      |      ^~~~~~
rotate.h:4:30: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<int>'
    4 | void rotate(std::vector<int> t, int x);
      |             ~~~~~~~~~~~~~~~~~^