제출 #1367011

#제출 시각아이디문제언어결과실행 시간메모리
1367011eyadooz저울 (IOI15_scales)C++20
컴파일 에러
0 ms0 KiB
#include "scales.h"
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define endl '\n'


void init(int T) {
    /* ... */
}

void orderCoins() {
    int W[] = {1, 2, 3, 4, 5, 6};
    vector<int> a, b;
    a.pb(getLightest(1, 2, 3));  
    a.pb(getMedian(1, 2, 3));  
    a.pb(getHeaviest(1, 2, 3));
    b.pb(getLightest(4, 5, 6));  
    b.pb(getMedian(4, 5, 6));  
    b.pb(getHeaviest(4, 5, 6));
    vector<int> s;
    while(min(sz(a), sz(b))>=1&&sz(a)+sz(b)>=3) {
        if(sz(a)<sz(b)) swap(a, b);
        auto it=getLightest(a[0], a[1], b[0]);
        s.pb(it);
        erase(all(a), it);
        erase(all(b), it);
    }
    if(sz(a)&&sz(b)) {
        auto it=getMedian(a[0], b[0], s.back());
        s.pb(it);
        erase(all(a), it);
        erase(all(b), it);
        if(sz(a)) s.pb(a.back());
        else s.pb(b.back());
    }
    else {
        reverse(all(a));
        reverse(all(b));
        while(sz(a)) s.pb(a.back()), a.pop_back();
        while(sz(b)) s.pb(b.back()), b.pop_back();
    }
    answer(s);
}
    

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

scales.cpp: In function 'void orderCoins()':
scales.cpp:33:14: error: no matching function for call to 'erase(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   33 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from scales.cpp:2:
/usr/include/c++/13/string:103:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc, class _Up> constexpr typename std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::erase(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _Up&)'
  103 |     erase(basic_string<_CharT, _Traits, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/string:103:5: note:   template argument deduction/substitution failed:
scales.cpp:33:14: note:   'std::vector<int>::iterator' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   33 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/vector:130:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> constexpr typename std::vector<_Tp, _Alloc>::size_type std::erase(vector<_Tp, _Alloc>&, const _Up&)'
  130 |     erase(vector<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/vector:130:5: note:   template argument deduction/substitution failed:
scales.cpp:33:14: note:   'std::vector<int>::iterator' is not derived from 'std::vector<_Tp, _Alloc>'
   33 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:139:
/usr/include/c++/13/deque:118:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::deque<_Tp, _Alloc>::size_type std::erase(deque<_Tp, _Alloc>&, const _Up&)'
  118 |     erase(deque<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/deque:118:5: note:   template argument deduction/substitution failed:
scales.cpp:33:14: note:   'std::vector<int>::iterator' is not derived from 'std::deque<_Tp, _Alloc>'
   33 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:150:
/usr/include/c++/13/list:100:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::__cxx11::list<_Tp, _Alloc>::size_type std::erase(__cxx11::list<_Tp, _Alloc>&, const _Up&)'
  100 |     erase(list<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/list:100:5: note:   template argument deduction/substitution failed:
scales.cpp:33:14: note:   'std::vector<int>::iterator' is not derived from 'std::__cxx11::list<_Tp, _Alloc>'
   33 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:175:
/usr/include/c++/13/forward_list:76:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::forward_list<_Tp, _Alloc>::size_type std::erase(forward_list<_Tp, _Alloc>&, const _Up&)'
   76 |     erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/forward_list:76:5: note:   template argument deduction/substitution failed:
scales.cpp:33:14: note:   'std::vector<int>::iterator' is not derived from 'std::forward_list<_Tp, _Alloc>'
   33 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
scales.cpp:34:14: error: no matching function for call to 'erase(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   34 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/string:103:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc, class _Up> constexpr typename std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::erase(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _Up&)'
  103 |     erase(basic_string<_CharT, _Traits, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/string:103:5: note:   template argument deduction/substitution failed:
scales.cpp:34:14: note:   'std::vector<int>::iterator' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   34 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/vector:130:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> constexpr typename std::vector<_Tp, _Alloc>::size_type std::erase(vector<_Tp, _Alloc>&, const _Up&)'
  130 |     erase(vector<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/vector:130:5: note:   template argument deduction/substitution failed:
scales.cpp:34:14: note:   'std::vector<int>::iterator' is not derived from 'std::vector<_Tp, _Alloc>'
   34 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/deque:118:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::deque<_Tp, _Alloc>::size_type std::erase(deque<_Tp, _Alloc>&, const _Up&)'
  118 |     erase(deque<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/deque:118:5: note:   template argument deduction/substitution failed:
scales.cpp:34:14: note:   'std::vector<int>::iterator' is not derived from 'std::deque<_Tp, _Alloc>'
   34 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/list:100:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::__cxx11::list<_Tp, _Alloc>::size_type std::erase(__cxx11::list<_Tp, _Alloc>&, const _Up&)'
  100 |     erase(list<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/list:100:5: note:   template argument deduction/substitution failed:
scales.cpp:34:14: note:   'std::vector<int>::iterator' is not derived from 'std::__cxx11::list<_Tp, _Alloc>'
   34 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/forward_list:76:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::forward_list<_Tp, _Alloc>::size_type std::erase(forward_list<_Tp, _Alloc>&, const _Up&)'
   76 |     erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/forward_list:76:5: note:   template argument deduction/substitution failed:
scales.cpp:34:14: note:   'std::vector<int>::iterator' is not derived from 'std::forward_list<_Tp, _Alloc>'
   34 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
scales.cpp:39:14: error: no matching function for call to 'erase(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   39 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/string:103:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc, class _Up> constexpr typename std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::erase(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _Up&)'
  103 |     erase(basic_string<_CharT, _Traits, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/string:103:5: note:   template argument deduction/substitution failed:
scales.cpp:39:14: note:   'std::vector<int>::iterator' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   39 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/vector:130:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> constexpr typename std::vector<_Tp, _Alloc>::size_type std::erase(vector<_Tp, _Alloc>&, const _Up&)'
  130 |     erase(vector<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/vector:130:5: note:   template argument deduction/substitution failed:
scales.cpp:39:14: note:   'std::vector<int>::iterator' is not derived from 'std::vector<_Tp, _Alloc>'
   39 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/deque:118:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::deque<_Tp, _Alloc>::size_type std::erase(deque<_Tp, _Alloc>&, const _Up&)'
  118 |     erase(deque<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/deque:118:5: note:   template argument deduction/substitution failed:
scales.cpp:39:14: note:   'std::vector<int>::iterator' is not derived from 'std::deque<_Tp, _Alloc>'
   39 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/list:100:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::__cxx11::list<_Tp, _Alloc>::size_type std::erase(__cxx11::list<_Tp, _Alloc>&, const _Up&)'
  100 |     erase(list<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/list:100:5: note:   template argument deduction/substitution failed:
scales.cpp:39:14: note:   'std::vector<int>::iterator' is not derived from 'std::__cxx11::list<_Tp, _Alloc>'
   39 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/forward_list:76:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::forward_list<_Tp, _Alloc>::size_type std::erase(forward_list<_Tp, _Alloc>&, const _Up&)'
   76 |     erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/forward_list:76:5: note:   template argument deduction/substitution failed:
scales.cpp:39:14: note:   'std::vector<int>::iterator' is not derived from 'std::forward_list<_Tp, _Alloc>'
   39 |         erase(all(a), it);
      |         ~~~~~^~~~~~~~~~~~
scales.cpp:40:14: error: no matching function for call to 'erase(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   40 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/string:103:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc, class _Up> constexpr typename std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::erase(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _Up&)'
  103 |     erase(basic_string<_CharT, _Traits, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/string:103:5: note:   template argument deduction/substitution failed:
scales.cpp:40:14: note:   'std::vector<int>::iterator' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   40 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/vector:130:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> constexpr typename std::vector<_Tp, _Alloc>::size_type std::erase(vector<_Tp, _Alloc>&, const _Up&)'
  130 |     erase(vector<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/vector:130:5: note:   template argument deduction/substitution failed:
scales.cpp:40:14: note:   'std::vector<int>::iterator' is not derived from 'std::vector<_Tp, _Alloc>'
   40 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/deque:118:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::deque<_Tp, _Alloc>::size_type std::erase(deque<_Tp, _Alloc>&, const _Up&)'
  118 |     erase(deque<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/deque:118:5: note:   template argument deduction/substitution failed:
scales.cpp:40:14: note:   'std::vector<int>::iterator' is not derived from 'std::deque<_Tp, _Alloc>'
   40 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/list:100:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::__cxx11::list<_Tp, _Alloc>::size_type std::erase(__cxx11::list<_Tp, _Alloc>&, const _Up&)'
  100 |     erase(list<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/list:100:5: note:   template argument deduction/substitution failed:
scales.cpp:40:14: note:   'std::vector<int>::iterator' is not derived from 'std::__cxx11::list<_Tp, _Alloc>'
   40 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
/usr/include/c++/13/forward_list:76:5: note: candidate: 'template<class _Tp, class _Alloc, class _Up> typename std::forward_list<_Tp, _Alloc>::size_type std::erase(forward_list<_Tp, _Alloc>&, const _Up&)'
   76 |     erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
      |     ^~~~~
/usr/include/c++/13/forward_list:76:5: note:   template argument deduction/substitution failed:
scales.cpp:40:14: note:   'std::vector<int>::iterator' is not derived from 'std::forward_list<_Tp, _Alloc>'
   40 |         erase(all(b), it);
      |         ~~~~~^~~~~~~~~~~~
scales.cpp:50:12: error: cannot convert 'std::vector<int>' to 'int*'
   50 |     answer(s);
      |            ^
      |            |
      |            std::vector<int>
In file included from scales.cpp:1:
scales.h:10:17: note:   initializing argument 1 of 'void answer(int*)'
   10 | void answer(int W[]);
      |             ~~~~^~~