Submission #1132230

#TimeUsernameProblemLanguageResultExecution timeMemory
1132230bobthescienceCombo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; std::string guess_sequence(int N) { string p = ""; int r = 1, ord; vector<char> add = {'A', 'B', 'X', 'Y'}; for (char c :add) { if (press("" + c)) { add.erase((char)c); break; } } while (r < n) { for (char c :add) { if (press(p + c) > r) { r++; p += c; break } } } return p; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:12:16: error: no matching function for call to 'std::vector<char>::erase(char)'
   12 |       add.erase((char)c);
      |       ~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from combo.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_vector.h:1430:28: note:   no known conversion for argument 1 from 'char' to 'std::vector<char>::const_iterator'
 1430 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/11/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++/11/bits/stl_vector.h:1457:7: note:   candidate expects 2 arguments, 1 provided
combo.cpp:16:14: error: 'n' was not declared in this scope
   16 |   while (r < n) {
      |              ^
combo.cpp:21:14: error: expected ';' before '}' token
   21 |         break
      |              ^
      |              ;
   22 |       }
      |       ~