Submission #401553

#TimeUsernameProblemLanguageResultExecution timeMemory
401553_DaNeK_Combo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector < char > m = {'A', 'B', 'Y', 'X'}; int press(string p); string guess_sequence(int N) { string res = ""; int cur = 1, i = 0, first = 0; while (i < 3 && press(res + m[i]) != cur) ++i; res += m[i]; m.erase(i); cur = 2; while (res.size() < N) { int ind = 0, cnt = 0; bool f = true; while (cnt < 2 && f) { if (press(res + m[ind]) == cur) f = false; if (f) { ++cnt; ++ind; } } ++cur; res += m[ind]; } return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:16:14: error: no matching function for call to 'std::vector<char>::erase(int&)'
   16 |     m.erase(i);
      |              ^
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:1:
/usr/include/c++/10/bits/stl_vector.h:1430:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = char; _Alloc = std::allocator<char>; std::vector<_Tp, _Alloc>::iterator = std::vector<char>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<char>::const_iterator]'
 1430 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1430:28: note:   no known conversion for argument 1 from 'int' to 'std::vector<char>::const_iterator'
 1430 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = char; _Alloc = std::allocator<char>; std::vector<_Tp, _Alloc>::iterator = std::vector<char>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<char>::const_iterator]'
 1457 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note:   candidate expects 2 arguments, 1 provided
combo.cpp:18:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     while (res.size() < N)
      |            ~~~~~~~~~~~^~~
combo.cpp:12:25: warning: unused variable 'first' [-Wunused-variable]
   12 |     int cur = 1, i = 0, first = 0;
      |                         ^~~~~