Submission #1142051

#TimeUsernameProblemLanguageResultExecution timeMemory
1142051jokerCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h" #include <unordered_set> #include <unordered_map> #include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> #include <iomanip> #include <numeric> std::string guess_sequence(int N) { string S = ""; vector<char> btns = ['X','Y','B','A']; int frstidx = -1; while (S.length() != N) { if (s.lenght() == 0) { for (let i = 0; i < 4; i++) { string st; st += btns[i]; int coin = press(st); if (coin == 1) { frstidx = i; S += btns[i]; break; } } } else { for (size_t i = 0; i < 4; i++) { if (i != frstidx) { string st = S+btns[i]; int coin = press(st); if (coin == S.length()+1) { S += btns[i]; break; } } } } } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:3: error: 'string' was not declared in this scope
   13 |   string S = "";
      |   ^~~~~~
combo.cpp:13: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:14:3: error: 'vector' was not declared in this scope
   14 |   vector<char> btns = ['X','Y','B','A'];
      |   ^~~~~~
combo.cpp:14:3: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
                 from combo.cpp:5:
/usr/include/c++/11/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from combo.cpp:5:
/usr/include/c++/11/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
combo.cpp:14:10: error: expected primary-expression before 'char'
   14 |   vector<char> btns = ['X','Y','B','A'];
      |          ^~~~
combo.cpp:16:10: error: 'S' was not declared in this scope
   16 |   while (S.length() != N) {
      |          ^
combo.cpp:17:9: error: 's' was not declared in this scope
   17 |     if (s.lenght() == 0) {
      |         ^
combo.cpp:18:14: error: 'let' was not declared in this scope
   18 |         for (let i = 0; i < 4; i++) {
      |              ^~~
combo.cpp:18:25: error: 'i' was not declared in this scope
   18 |         for (let i = 0; i < 4; i++) {
      |                         ^
combo.cpp:19:19: error: expected ';' before 'st'
   19 |             string st;
      |                   ^~~
      |                   ;
combo.cpp:20:13: error: 'st' was not declared in this scope; did you mean 'std'?
   20 |             st += btns[i];
      |             ^~
      |             std
combo.cpp:20:19: error: 'btns' was not declared in this scope
   20 |             st += btns[i];
      |                   ^~~~
combo.cpp:31:23: error: expected ';' before 'st'
   31 |                 string st = S+btns[i];
      |                       ^~~
      |                       ;
combo.cpp:32:34: error: 'st' was not declared in this scope; did you mean 'std'?
   32 |                 int coin = press(st);
      |                                  ^~
      |                                  std
combo.cpp:34:26: error: 'btns' was not declared in this scope
   34 |                     S += btns[i];
      |                          ^~~~
combo.cpp:41:10: error: 'S' was not declared in this scope
   41 |   return S;
      |          ^