Submission #1142527

#TimeUsernameProblemLanguageResultExecution timeMemory
1142527joker2Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h" std::string guess_sequence(int N) { string S = ""; vector<char> btns = {'A','B','X','Y'}; while (S.length() != N) { if (S.length() == 0) { int coin = press("AB"); if (coin > 0) { coin = press("A"); if (coin == 1) { S += 'A'; btns.erase(btns.begin()); } else { S += 'B'; btns.erase(btns.begin()+1); } } else { coin = press("X"); if (coin == 1) { S += 'X'; btns.erase(btns.begin()+2); } else { S += 'Y'; btns.erase(btns.begin()+3); } } } else if (S.length() < N) { string message = ""; message += S; message += btns[0]; for (size_t i = 0; i < 3; i++) { message += S; message += btns[1] + btns[i]; } int coin = press(message); if (coin == S.length()+1) { S += btns[0]; } else if (coin == S.length() + 2) { S += btns[1]; } else { S += btns[2]; } } else { int coin = press(S+btns[0]+btns[1]); if (coin > S.length()) { coin = press(S+btns[0]); if (coin == 1) { S += btns[0]; } else { S += btns[1]; } } else { S += btns[2]; } } } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:4:3: error: 'string' was not declared in this scope
    4 |   string S = "";
      |   ^~~~~~
combo.cpp:4:3: note: suggested alternatives:
In file included from /usr/include/c++/11/string:39,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/11/bits/stringfwd.h:79:33: note:   'std::string'
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/11/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
combo.cpp:5:3: error: 'vector' was not declared in this scope
    5 |   vector<char> btns = {'A','B','X','Y'};
      |   ^~~~~~
combo.cpp:5:10: error: expected primary-expression before 'char'
    5 |   vector<char> btns = {'A','B','X','Y'};
      |          ^~~~
combo.cpp:6:10: error: 'S' was not declared in this scope
    6 |   while (S.length() != N) {
      |          ^
combo.cpp:13:17: error: 'btns' was not declared in this scope
   13 |                 btns.erase(btns.begin());
      |                 ^~~~
combo.cpp:16:17: error: 'btns' was not declared in this scope
   16 |                 btns.erase(btns.begin()+1);
      |                 ^~~~
combo.cpp:22:17: error: 'btns' was not declared in this scope
   22 |                 btns.erase(btns.begin()+2);
      |                 ^~~~
combo.cpp:25:17: error: 'btns' was not declared in this scope
   25 |                 btns.erase(btns.begin()+3);
      |                 ^~~~
combo.cpp:29:15: error: expected ';' before 'message'
   29 |         string message = "";
      |               ^~~~~~~~
      |               ;
combo.cpp:30:9: error: 'message' was not declared in this scope
   30 |         message += S;
      |         ^~~~~~~
combo.cpp:31:20: error: 'btns' was not declared in this scope
   31 |         message += btns[0];
      |                    ^~~~
combo.cpp:45:28: error: 'btns' was not declared in this scope
   45 |         int coin = press(S+btns[0]+btns[1]);
      |                            ^~~~
combo.cpp:58:10: error: 'S' was not declared in this scope
   58 |   return S;
      |          ^