Submission #1150594

#TimeUsernameProblemLanguageResultExecution timeMemory
1150594brover29Bubble Sort 2 (JOI18_bubblesort2)C++20
Compilation error
0 ms0 KiB
#include "bubblesort2.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const ll N=1e5+29; vector<int>B; vector<int> countScans(vector<int> A,vector<int> X,vector<int> V){ ll Q=X.size(); B=A; vector<int> answer(Q); for (int j=0;j<Q;j++) { A[X[j]]=V[j]; B=A; if(is_sorted(A.begin(),A.end)){ answer.push_back(0); continue; } sort(B.begin(),B.end()); ll cnt=0; for(ll i=B.size()-1;i>=0;i--){ if(B[i]==A[i]){ cnt++; }else break; } answer.push_back(A.size()-cnt-1); } return answer; }

Compilation message (stderr)

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:14:29: error: no matching function for call to 'is_sorted(std::vector<int>::iterator, <unresolved overloaded function type>)'
   14 |                 if(is_sorted(A.begin(),A.end)){
      |                    ~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:62,
                 from bubblesort2.h:1,
                 from bubblesort2.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3204:5: note: candidate: 'constexpr bool std::is_sorted(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
 3204 |     is_sorted(_ForwardIterator __first, _ForwardIterator __last)
      |     ^~~~~~~~~
/usr/include/c++/11/bits/stl_algo.h:3204:58: note:   no known conversion for argument 2 from '<unresolved overloaded function type>' to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >'
 3204 |     is_sorted(_ForwardIterator __first, _ForwardIterator __last)
      |                                         ~~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/11/bits/stl_algo.h:3219:5: note: candidate: 'template<class _FIter, class _Compare> constexpr bool std::is_sorted(_FIter, _FIter, _Compare)'
 3219 |     is_sorted(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~
/usr/include/c++/11/bits/stl_algo.h:3219:5: note:   template argument deduction/substitution failed:
bubblesort2.cpp:14:29: note:   candidate expects 3 arguments, 2 provided
   14 |                 if(is_sorted(A.begin(),A.end)){
      |                    ~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bubblesort2.cpp:2:
/usr/include/c++/11/pstl/glue_algorithm_defs.h:390:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, bool> std::is_sorted(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Compare)'
  390 | is_sorted(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Compare __comp);
      | ^~~~~~~~~
/usr/include/c++/11/pstl/glue_algorithm_defs.h:390:1: note:   template argument deduction/substitution failed:
bubblesort2.cpp:14:29: note:   candidate expects 4 arguments, 2 provided
   14 |                 if(is_sorted(A.begin(),A.end)){
      |                    ~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bubblesort2.cpp:2:
/usr/include/c++/11/pstl/glue_algorithm_defs.h:394:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, bool> std::is_sorted(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
  394 | is_sorted(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~
/usr/include/c++/11/pstl/glue_algorithm_defs.h:394:1: note:   template argument deduction/substitution failed:
bubblesort2.cpp:14:29: note:   candidate expects 3 arguments, 2 provided
   14 |                 if(is_sorted(A.begin(),A.end)){
      |                    ~~~~~~~~~^~~~~~~~~~~~~~~~~