Submission #1212937

#TimeUsernameProblemLanguageResultExecution timeMemory
1212937Rawlat_vanakRotating Lines (APIO25_rotate)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; //#define int long long #define speedIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); //#define mod 1000000007 #define f first #define s second #define pii pair<int,int> #define pb push_back const int M=50000; vector<int> final; void energy(int n, vector<int> v){ set<pii> a; map<pii,int> b; vector<pii> tmp(n); for(int i=0;i<n;i++){ a.insert({v[i],i}); tmp[i]={v[i],i}; } sort(tmp.begin(),tmp.end()); for(int i=0;i<n;i++){ b[{tmp[i].f,tmp[i].s}]=i; //cout<<tmp[i].f<<' '<<tmp[i].s<<'\n'; } vector<bool> marked(n,false); int idx=0; while(idx<n and !a.empty()){ if(marked[idx]){ //cout<<"hi\n"; idx++; continue; } if(tmp[idx].f<M/2){ auto it=a.upper_bound({tmp[idx].f+M/2,1e9}); // atmost v[i]+90 it--; pii sigh=*it; //cout<<sigh.s<<" plsplsplswork\n"; if(b[sigh]-idx>=(n)/2){ //cout<<"piuhperihgveirjv\n"; rotate({tmp[idx].s},tmp[b[sigh]].f+M/2-tmp[idx].f); a.erase({tmp[idx].f,tmp[idx].s}); a.insert({tmp[b[sigh]].f+M/2,tmp[idx].s}); tmp[idx].f=tmp[b[sigh]].f+M/2; marked[b[sigh]]=true; }else{ //cout<<"wpoejfpwepfo\n"; rotate({tmp[idx].s},tmp[(b[sigh]+1)%n].f+M/2-tmp[idx].f); a.erase({tmp[idx].f,tmp[idx].s}); a.insert({tmp[(b[sigh]+1)%n].f+M/2,tmp[idx].s}); tmp[idx].f=tmp[(b[sigh]+1)].f+M/2; marked[(b[sigh]+1)%n]=true; } }else{ auto it=a.lower_bound({tmp[idx].f-M/2,0}); // atleast v[i]+90 pii sigh=*it; if(idx-b[sigh]>=(n)/2){ rotate({tmp[idx].s},tmp[b[sigh]].f+M/2-tmp[idx].f); a.erase({tmp[idx].f,tmp[idx].s}); a.insert({tmp[b[sigh]].f+M/2,tmp[idx].s}); tmp[idx].f=tmp[b[sigh]].f+M/2; marked[b[sigh]]=true; }else{ rotate({tmp[idx].s},tmp[(b[sigh]-1)%n].f+M/2-tmp[idx].f); a.erase({tmp[idx].f,tmp[idx].s}); a.insert({tmp[(b[sigh]-1)%n].f+M/2,tmp[idx].s}); tmp[idx].f=tmp[(b[sigh]-1)].f+M/2; marked[(b[sigh]-1)%n]=true; } } marked[idx]=true; idx++; } }

Compilation message (stderr)

rotate.cpp: In function 'void energy(int, std::vector<int>)':
rotate.cpp:46:39: error: no matching function for call to 'rotate(<brace-enclosed initializer list>, int)'
   46 |                                 rotate({tmp[idx].s},tmp[b[sigh]].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 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:46:39: note:   candidate expects 3 arguments, 2 provided
   46 |                                 rotate({tmp[idx].s},tmp[b[sigh]].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:1:
/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:46:39: note:   candidate expects 4 arguments, 2 provided
   46 |                                 rotate({tmp[idx].s},tmp[b[sigh]].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rotate.cpp:53:39: error: no matching function for call to 'rotate(<brace-enclosed initializer list>, int)'
   53 |                                 rotate({tmp[idx].s},tmp[(b[sigh]+1)%n].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 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:53:39: note:   candidate expects 3 arguments, 2 provided
   53 |                                 rotate({tmp[idx].s},tmp[(b[sigh]+1)%n].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:1:
/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:53:39: note:   candidate expects 4 arguments, 2 provided
   53 |                                 rotate({tmp[idx].s},tmp[(b[sigh]+1)%n].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rotate.cpp:64:39: error: no matching function for call to 'rotate(<brace-enclosed initializer list>, int)'
   64 |                                 rotate({tmp[idx].s},tmp[b[sigh]].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 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:64:39: note:   candidate expects 3 arguments, 2 provided
   64 |                                 rotate({tmp[idx].s},tmp[b[sigh]].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:1:
/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:64:39: note:   candidate expects 4 arguments, 2 provided
   64 |                                 rotate({tmp[idx].s},tmp[b[sigh]].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rotate.cpp:70:39: error: no matching function for call to 'rotate(<brace-enclosed initializer list>, int)'
   70 |                                 rotate({tmp[idx].s},tmp[(b[sigh]-1)%n].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 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:70:39: note:   candidate expects 3 arguments, 2 provided
   70 |                                 rotate({tmp[idx].s},tmp[(b[sigh]-1)%n].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:1:
/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:70:39: note:   candidate expects 4 arguments, 2 provided
   70 |                                 rotate({tmp[idx].s},tmp[(b[sigh]-1)%n].f+M/2-tmp[idx].f);
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~