Submission #1132216

#TimeUsernameProblemLanguageResultExecution timeMemory
1132216bobthescienceCombo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h" 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(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:4:3: error: 'string' was not declared in this scope
    4 |   string p = "";
      |   ^~~~~~
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:6:3: error: 'vector' was not declared in this scope
    6 |   vector<char> add = {'A', 'B', 'X', 'Y'};
      |   ^~~~~~
combo.cpp:6:10: error: expected primary-expression before 'char'
    6 |   vector<char> add = {'A', 'B', 'X', 'Y'};
      |          ^~~~
combo.cpp:7:16: error: 'add' was not declared in this scope
    7 |   for (char c :add) {
      |                ^~~
combo.cpp:8:15: error: could not convert 'c' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
    8 |     if (press(c)) {
      |               ^
      |               |
      |               char
combo.cpp:13:14: error: 'n' was not declared in this scope
   13 |   while (r < n) {
      |              ^
combo.cpp:14:18: error: 'add' was not declared in this scope
   14 |     for (char c :add) {
      |                  ^~~
combo.cpp:15:17: error: 'p' was not declared in this scope
   15 |       if (press(p + c) > r) {
      |                 ^
combo.cpp:18:14: error: expected ';' before '}' token
   18 |         break
      |              ^
      |              ;
   19 |       }
      |       ~       
combo.cpp:22:10: error: 'p' was not declared in this scope
   22 |   return p;
      |          ^