Submission #439186

#TimeUsernameProblemLanguageResultExecution timeMemory
439186IdkwhoamiCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" #include "combo.h" using namespace std; string guess_sequence(int N) { string ans = "Y"; vector<string> tf = {"A", "B", "X"}, possible = {"A", "B", "X", "Y"}; for(auto t:tf){ int x = press(t); if(x == 1) { ans = t; break; } } possible.erase(ans); string start = ans; if(N == 1)ans; while(ans.size() != N){ string test1 = ans + possible[0] + ans + possible[1]; int x = press(test1); if(x == ans.size()){ ans = ans + possible[2]; } else{ x = press(ans + possible[0]); if(x == ans.size())ans = ans + possible[1]; else ans = ans + possible[0]; } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:17:23: error: no matching function for call to 'std::vector<std::__cxx11::basic_string<char> >::erase(std::string&)'
   17 |     possible.erase(ans);
      |                       ^
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 = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::__cxx11::basic_string<char> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::__cxx11::basic_string<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 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::vector<std::__cxx11::basic_string<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 = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::__cxx11::basic_string<char> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::__cxx11::basic_string<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:19:15: warning: statement has no effect [-Wunused-value]
   19 |     if(N == 1)ans;
      |               ^~~
combo.cpp:21:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |     while(ans.size() != N){
      |           ~~~~~~~~~~~^~~~
combo.cpp:26:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if(x == ans.size()){
      |            ~~^~~~~~~~~~~~~
combo.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             if(x == ans.size())ans = ans + possible[1];
      |                ~~^~~~~~~~~~~~~