제출 #356626

#제출 시각아이디문제언어결과실행 시간메모리
356626BlancaHM저울 (IOI15_scales)C++14
컴파일 에러
0 ms0 KiB
#include "scales.h" #include <algorithm> #include <vector> using namespace std; void permutaciones(vector<int> & permutacion, vector<bool> & seleccionado, int N, vector<vector<int>> & perm) { if ((int) permutacion.size() == N) { // ya están todos los números en la permutación perm.push_back(permutacion); return; } for (int i = 1; i <= N; i++) { if (!seleccionado[i-1]) { seleccionado[i-1] = true; permutacion.push_back(i); permutaciones(permutacion, seleccionado, N, perm); permutacion.pop_back(); seleccionado[i-1] = false; } } } void reducir(vector<int> secuencia, vector<vector<int>> & perm) { vector<vector<int>> solucion = {}; int i, j; for (int k = 0; k < (int) perm.size(); k++) { i = j = 0; while(i < (int) secuencia.size() && j < 6) { if (perm[j] == secuencia[i]) { i++; j++; } else j++; } if (i == (int) secuencia.size()) solucion.push_back(perm[k]); } perm = solucion; } void orderCoins() { vector<vector<int>> perm; // guardamos aquí las permutaciones de los números 1 a 6 vector<int> p = {}; vector<bool> sel = vector<bool>(6, false); permutaciones(p, sel, 6, perm); int respuesta, A, B, C; while((int) perm.size() > 1) { A = perm[0][0]; B = perm[0][1]; C = perm[0][2]; respuesta = getHeaviest(A, B, C); if (respuesta == A) { reducir({B, A}, perm); reducir({C, A}, perm); } else if (respuesta == B) { reducir({A, B}, perm); reducir({C, B}, perm); } else { reducir({A, C}, perm); reducir({B, C}, perm); } } p = perm[0]; answer({p[0], p[1], p[2], p[3], p[4], p[5]}); }

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

scales.cpp: In function 'void reducir(std::vector<int>, std::vector<std::vector<int> >&)':
scales.cpp:30:16: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   30 |    if (perm[j] == secuencia[i]) {
In file included from /usr/include/c++/9/utility:70,
                 from /usr/include/c++/9/algorithm:60,
                 from scales.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:448:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)'
  448 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_pair.h:448:5: note:   template argument deduction/substitution failed:
scales.cpp:30:30: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::pair<_T1, _T2>'
   30 |    if (perm[j] == secuencia[i]) {
      |                              ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/algorithm:61,
                 from scales.cpp:2:
/usr/include/c++/9/bits/stl_iterator.h:325:5: note: candidate: 'template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)'
  325 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:325:5: note:   template argument deduction/substitution failed:
scales.cpp:30:30: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
   30 |    if (perm[j] == secuencia[i]) {
      |                              ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/algorithm:61,
                 from scales.cpp:2:
/usr/include/c++/9/bits/stl_iterator.h:363:5: note: candidate: 'template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)'
  363 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:363:5: note:   template argument deduction/substitution failed:
scales.cpp:30:30: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
   30 |    if (perm[j] == secuencia[i]) {
      |                              ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/algorithm:61,
                 from scales.cpp:2:
/usr/include/c++/9/bits/stl_iterator.h:1139:5: note: candidate: 'template<class _IteratorL, class _IteratorR> bool std::operator==(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)'
 1139 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:1139:5: note:   template argument deduction/substitution failed:
scales.cpp:30:30: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::move_iterator<_IteratorL>'
   30 |    if (perm[j] == secuencia[i]) {
      |                              ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/algorithm:61,
                 from scales.cpp:2:
/usr/include/c++/9/bits/stl_iterator.h:1145:5: note: candidate: 'template<class _Iterator> bool std::operator==(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)'
 1145 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:1145:5: note:   template argument deduction/substitution failed:
scales.cpp:30:30: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::move_iterator<_IteratorL>'
   30 |    if (perm[j] == secuencia[i]) {
      |                              ^
In file included from /usr/include/c++/9/vector:64,
                 from scales.cpp:3:
/usr/include/c++/9/bits/allocator.h:168:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const std::allocator<_Tp>&, const std::allocator<_Tp>&)'
  168 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/9/bits/allocator.h:168:5: note:   template argument deduction/substitution failed:
scales.cpp:30:30: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::allocator<_Tp>'
   30 |    if (perm[j] == secuencia[i]) {
      |                              ^
In file included from /usr/include/c++/9/vector:67,
                 from scales.cpp:3:
/usr/include/c++/9/bits/stl_vector.h:1888:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator==(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)'
 1888 |     operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1888:5: note:   template argument deduction/substitution failed:
scales.cpp:30:30: note:   mismatched types 'const std::vector<_Tp, _Alloc>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   30 |    if (perm[j] == secuencia[i]) {
      |                              ^
In file included from /usr/include/c++/9/vector:64,
                 from scales.cpp:3:
/usr/include/c++/9/bits/allocator.h:156:7: note: candidate: 'bool std::operator==(const std::allocator<int>&, const std::allocator<int>&)'
  156 |       operator==(const allocator&, const allocator&) _GLIBCXX_NOTHROW
      |       ^~~~~~~~
/usr/include/c++/9/bits/allocator.h:156:18: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'const std::allocator<int>&'
  156 |       operator==(const allocator&, const allocator&) _GLIBCXX_NOTHROW
      |                  ^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/algorithm:61,
                 from scales.cpp:2:
/usr/include/c++/9/bits/stl_iterator.h:886:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)'
  886 |     operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:886:5: note:   template argument deduction/substitution failed:
scales.cpp:30:30: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
   30 |    if (perm[j] == secuencia[i]) {
      |                              ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/algorithm:61,
                 from scales.cpp:2:
/usr/include/c++/9/bits/stl_iterator.h:893:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)'
  893 |     operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:893:5: note:   template argument deduction/substitution failed:
scales.cpp:30:30: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   30 |    if (perm[j] == secuencia[i]) {
      |                              ^
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from scales.cpp:3:
/usr/include/c++/9/ext/new_allocator.h:167:2: note: candidate: 'template<class _Up> bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator<int>&, const __gnu_cxx::new_allocator<_Tp>&)'
  167 |  operator==(const new_allocator&, const new_allocator<_Up>&)
      |  ^~~~~~~~
/usr/include/c++/9/ext/new_allocator.h:167:2: note:   template argument deduction/substitution failed:
scales.cpp:30:30: note:   mismatched types 'const __gnu_cxx::new_allocator<_Tp>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   30 |    if (perm[j] == secuencia[i]) {
      |                              ^
scales.cpp: In function 'void orderCoins()':
scales.cpp:64:45: error: cannot convert '<brace-enclosed initializer list>' to 'int*'
   64 |  answer({p[0], p[1], p[2], p[3], p[4], p[5]});
      |                                             ^
      |                                             |
      |                                             <brace-enclosed initializer list>
In file included from scales.cpp:1:
scales.h:10:17: note:   initializing argument 1 of 'void answer(int*)'
   10 | void answer(int W[]);
      |             ~~~~^~~