Submission #866693

#TimeUsernameProblemLanguageResultExecution timeMemory
866693vjudge1콤보 (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include<iostream> #include<string> #include<vector> using namespace std; // int press(string s){ // return 1; // } string guess_sequence(int n){ vector<char>buttons = {'A','B','X','Y'}; char starting_char = '0'; if(press("AB")){ if(press("A")) starting_char = 'A'; else starting_char = 'B'; } else{ if(press("X")) starting_char = 'X'; else starting_char = 'Y'; } string ans{starting_char}; buttons.erase(find(buttons.begin(), buttons.end(), starting_char)); // s + B + s + XY + s + XB + s + XX -> if starting_char == A for(int i = 2; i < n; ++i){ int current_coins = press(ans + string{buttons[0]} + ans + string{buttons[1],buttons[2]} + ans + string{buttons[1], buttons[1]} + ans + string{buttons[1], buttons[1]}); if(current_coins == i) ans.push_back(buttons[2]); else if(current_coins == i + 1) ans.push_back(buttons[0]); else if(current_coins == i + 2) ans.push_back(buttons[1]); } if(press(ans + string{buttons[0], buttons[1]}) == n){ if(press(ans + string{buttons[0]}) == n) ans.push_back(buttons[0]); else ans.push_back(buttons[1]); } else{ ans.push_back(buttons[2]); } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:8: error: 'press' was not declared in this scope
   13 |     if(press("AB")){
      |        ^~~~~
combo.cpp:26:69: error: no matching function for call to 'find(std::vector<char>::iterator, std::vector<char>::iterator, char&)'
   26 |     buttons.erase(find(buttons.begin(), buttons.end(), starting_char));
      |                                                                     ^
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:1:
/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:26:69: note:   '__gnu_cxx::__normal_iterator<char*, std::vector<char> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   26 |     buttons.erase(find(buttons.begin(), buttons.end(), starting_char));
      |                                                                     ^
combo.cpp:30:29: error: 'press' was not declared in this scope
   30 |         int current_coins = press(ans + string{buttons[0]} + ans + string{buttons[1],buttons[2]} + ans
      |                             ^~~~~
combo.cpp:40:8: error: 'press' was not declared in this scope
   40 |     if(press(ans + string{buttons[0], buttons[1]}) == n){
      |        ^~~~~