Submission #113497

#TimeUsernameProblemLanguageResultExecution timeMemory
113497Mamnoon_SiamCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string ret; vector<int> R = {'A', 'B', 'X', 'Y'}; set<char> r(R.begin(), R.end()); if(press("AB")) { if(press("A")) ret += "A", r.erase('A'); else ret += "B", r.erase('B'); } else { if(press("X")) ret += "X", r.erase('X'); else ret += "Y", r.erase('Y'); } if(N == 1) return ret; R = vector(r.begin(), r.end()); for(int i = 2; i < N; i++) { string tmp; tmp += ret, tmp += R[0]; for(char ch : R) { tmp += ret, tmp += R[1], tmp += ch; } int rep = press(tmp); if(rep == ret.size()) ret += R[2]; else if(rep == ret.size() + 1) ret += R[0]; else ret += R[1]; } for(int k = 0; k < 2; k++) { string tmp = ret; tmp += R[k]; if(press(tmp) == N) { ret += R[k]; break; } } if(ret.size() != N) ret += R[2]; return ret; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:17:34: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<char, std::allocator<char> >')
   17 |     R = vector(r.begin(), r.end());
      |                                  ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from combo.cpp:2:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<char, std::allocator<char> >' to 'const std::vector<int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from combo.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<char, std::allocator<char> >' to 'std::vector<int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<char, std::allocator<char> >' to 'std::initializer_list<int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
combo.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(rep == ret.size()) ret += R[2];
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:26:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         else if(rep == ret.size() + 1) ret += R[0];
      |                 ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:37:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |     if(ret.size() != N) ret += R[2];
      |        ~~~~~~~~~~~^~~~