Submission #894414

#TimeUsernameProblemLanguageResultExecution timeMemory
894414AtabayRajabliCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> std::string guess_sequence(int N) { string p = "ABXY"; string res = ""; if(press("A"))res = "A"; else if(press("B"))res = "B"; else if(press("X"))res = "X"; else (press("Y"))res = "Y"; while(res.size() < N) { for(char c : p) { if(c == res[0])continue; if(press(res + c) == res.size() + 1) { res += c; break; } } } return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:3: error: 'string' was not declared in this scope
    6 |   string p = "ABXY";
      |   ^~~~~~
combo.cpp:6:3: note: suggested alternatives:
In file included from /usr/include/c++/10/string:39,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/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++/10/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
combo.cpp:7:9: error: expected ';' before 'res'
    7 |   string res = "";
      |         ^~~~
      |         ;
combo.cpp:8:17: error: 'res' was not declared in this scope
    8 |   if(press("A"))res = "A";
      |                 ^~~
combo.cpp:9:22: error: 'res' was not declared in this scope
    9 |   else if(press("B"))res = "B";
      |                      ^~~
combo.cpp:10:22: error: 'res' was not declared in this scope
   10 |   else if(press("X"))res = "X";
      |                      ^~~
combo.cpp:11:20: error: expected ';' before 'res'
   11 |   else (press("Y"))res = "Y";
      |                    ^~~
      |                    ;
combo.cpp:13:9: error: 'res' was not declared in this scope
   13 |   while(res.size() < N)
      |         ^~~
combo.cpp:15:18: error: 'p' was not declared in this scope
   15 |     for(char c : p)
      |                  ^
combo.cpp:26:10: error: 'res' was not declared in this scope
   26 |   return res;
      |          ^~~