Submission #536413

#TimeUsernameProblemLanguageResultExecution timeMemory
536413timreizinCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h" #include <iostream> #include <vector> using namespace std; string guess_sequence(int n) { string s = ""; if (press("AB") >= 1) { if (press("A") >= 1) s += 'A'; else s += 'B'; } else { if (press("X") >= 1) s += 'X'; else s += 'Y'; } vector<char> chars{'A', 'B', 'X', 'Y'}; chars.erase(find(chars.begin(), chars.end(), s.front())); for (int i = 1; i + 1 < n; ++i) { int c = press(s + chars[0] + s + chars[1] + chars[0] + s + chars[1] + chars[1] + s + chars[1] + chars[2]); if (c == i) s += chars[2]; else if (c == i + 1) s += chars[0]; else s += chars[1]; } if (press(s + 'A' + s + 'B') == n) { if (press(s + 'A') == n) s += 'A'; else s += 'B'; } else { if (press(s + 'X') == n) s += 'X'; else s += 'Y'; } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:21:59: error: no matching function for call to 'find(std::vector<char>::iterator, std::vector<char>::iterator, __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)'
   21 |     chars.erase(find(chars.begin(), chars.end(), s.front()));
      |                                                           ^
In file included from /usr/include/c++/10/bits/locale_facets.h:48,
                 from /usr/include/c++/10/bits/basic_ios.h:37,
                 from /usr/include/c++/10/ios:44,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from combo.cpp:2:
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&)'
  422 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note:   template argument deduction/substitution failed:
combo.cpp:21:59: note:   '__gnu_cxx::__normal_iterator<char*, std::vector<char> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   21 |     chars.erase(find(chars.begin(), chars.end(), s.front()));
      |                                                           ^