제출 #1329977

#제출 시각아이디문제언어결과실행 시간메모리
1329977KhoaDuyRotating Lines (APIO25_rotate)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
// void rotate(vector<int> t,int x){

// }
const int deg90=25000,deg180=50000;
void energy(int n,vector<int> v){
    vector<pair<int,int>> order(n);
    for(int i=0;i<n;i++){
        order[i]={v[i],i};
    }
    sort(order.begin(),order.end());
    while(order.size()>1){
        if(order[0].first>=deg90){
            for(int i=0;i<order.size()-1-i;i++){
                rotate({order[i].second},deg180-(order[i].first-deg90));
                rotate({order[order.size()-1-i].second},deg180-order[order.size()-1-i].first);
            }
            return;
        }
        vector<int> le,ri;
        bool flag=false;
        for(int i=1;i<order.size();i++){
            if(order[i].first==order[0].first+deg90){
                flag=true;
                order.erase(order.begin()+i);
                break;
            }
            else if(order[i].first<order[0].first+deg90){
                le.push_back(i);
            }
            else{
                ri.push_back(i);
            }
        }
        if(flag){
            order.erase(order.begin());
            continue;
        }
        if(le.size()>=ri.size()){
            int idx=le.back();
            rotate({idx},order[0].first+deg90-order[idx].first);
            order.erase(order.begin()+idx);
        }
        else{
            int idx=ri[0];
            rotate({idx},deg180-(order[idx].first-order[0].first-deg90));
            order.erase(order.begin()+idx);
        }
        order.erase(order.begin());
    }
}

컴파일 시 표준 에러 (stderr) 메시지

rotate.cpp: In function 'void energy(int, std::vector<int>)':
rotate.cpp:18:23: error: no matching function for call to 'rotate(<brace-enclosed initializer list>, int)'
   18 |                 rotate({order[i].second},deg180-(order[i].first-deg90));
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from rotate.cpp:1:
/usr/include/c++/13/bits/stl_algo.h:1390:5: note: candidate: 'template<class _FIter> constexpr _FIter std::_V2::rotate(_FIter, _FIter, _FIter)'
 1390 |     rotate(_ForwardIterator __first, _ForwardIterator __middle,
      |     ^~~~~~
/usr/include/c++/13/bits/stl_algo.h:1390:5: note:   template argument deduction/substitution failed:
rotate.cpp:18:23: note:   candidate expects 3 arguments, 2 provided
   18 |                 rotate({order[i].second},deg180-(order[i].first-deg90));
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:73:
/usr/include/c++/13/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++/13/pstl/glue_algorithm_defs.h:260:1: note:   template argument deduction/substitution failed:
rotate.cpp:18:23: note:   candidate expects 4 arguments, 2 provided
   18 |                 rotate({order[i].second},deg180-(order[i].first-deg90));
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rotate.cpp:19:23: error: no matching function for call to 'rotate(<brace-enclosed initializer list>, int)'
   19 |                 rotate({order[order.size()-1-i].second},deg180-order[order.size()-1-i].first);
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:1390:5: note: candidate: 'template<class _FIter> constexpr _FIter std::_V2::rotate(_FIter, _FIter, _FIter)'
 1390 |     rotate(_ForwardIterator __first, _ForwardIterator __middle,
      |     ^~~~~~
/usr/include/c++/13/bits/stl_algo.h:1390:5: note:   template argument deduction/substitution failed:
rotate.cpp:19:23: note:   candidate expects 3 arguments, 2 provided
   19 |                 rotate({order[order.size()-1-i].second},deg180-order[order.size()-1-i].first);
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/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++/13/pstl/glue_algorithm_defs.h:260:1: note:   template argument deduction/substitution failed:
rotate.cpp:19:23: note:   candidate expects 4 arguments, 2 provided
   19 |                 rotate({order[order.size()-1-i].second},deg180-order[order.size()-1-i].first);
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rotate.cpp:44:19: error: no matching function for call to 'rotate(<brace-enclosed initializer list>, int)'
   44 |             rotate({idx},order[0].first+deg90-order[idx].first);
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:1390:5: note: candidate: 'template<class _FIter> constexpr _FIter std::_V2::rotate(_FIter, _FIter, _FIter)'
 1390 |     rotate(_ForwardIterator __first, _ForwardIterator __middle,
      |     ^~~~~~
/usr/include/c++/13/bits/stl_algo.h:1390:5: note:   template argument deduction/substitution failed:
rotate.cpp:44:19: note:   candidate expects 3 arguments, 2 provided
   44 |             rotate({idx},order[0].first+deg90-order[idx].first);
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/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++/13/pstl/glue_algorithm_defs.h:260:1: note:   template argument deduction/substitution failed:
rotate.cpp:44:19: note:   candidate expects 4 arguments, 2 provided
   44 |             rotate({idx},order[0].first+deg90-order[idx].first);
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rotate.cpp:49:19: error: no matching function for call to 'rotate(<brace-enclosed initializer list>, int)'
   49 |             rotate({idx},deg180-(order[idx].first-order[0].first-deg90));
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:1390:5: note: candidate: 'template<class _FIter> constexpr _FIter std::_V2::rotate(_FIter, _FIter, _FIter)'
 1390 |     rotate(_ForwardIterator __first, _ForwardIterator __middle,
      |     ^~~~~~
/usr/include/c++/13/bits/stl_algo.h:1390:5: note:   template argument deduction/substitution failed:
rotate.cpp:49:19: note:   candidate expects 3 arguments, 2 provided
   49 |             rotate({idx},deg180-(order[idx].first-order[0].first-deg90));
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/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++/13/pstl/glue_algorithm_defs.h:260:1: note:   template argument deduction/substitution failed:
rotate.cpp:49:19: note:   candidate expects 4 arguments, 2 provided
   49 |             rotate({idx},deg180-(order[idx].first-order[0].first-deg90));
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~