Submission #963861

#TimeUsernameProblemLanguageResultExecution timeMemory
963861TAhmed33Combo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h" using namespace std; char getfirst () { string u = "AB"; int y = press(u); if (y >= 1) { u = "A"; y = press(u); if (y == 1) return 'A'; return 'B'; } else { u = "X"; y = press(u); if (y == 1) return 'X'; return 'Y'; } } string guess_sequence (int n) { char x = getfirst(); vector <char> dd = {'A', 'B', 'X', 'Y'}; for (int i = 0; i < 4; i++) { if (dd[i] == x) { dd.erase(dd.begin() + i); } } string ret; ret += x; if (n == 1) return ret; for (int i = 2; i < n; i++) { string f1 = ret; f1 += dd[0]; f1 += dd[0]; string f2 = ret; f2 += dd[0]; f2 += dd[1]; string f3 = ret; f3 += dd[0]; f3 += dd[2]; string f4 = ret; f4 += dd[1]; string g = f1 + f2 + f3 + f4; int y = press(g); if (y == i - 1) { ret += dd[2]; } else if (y == i) { ret += dd[1]; } else { ret += dd[0]; } } for (int i = 0; i < 2; i++) { string u = ret; u += dd[i]; int g = press(u); if (g == n) { ret = u; break; } if (i == 1) ret += dd[2]; } return ret; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:3: error: 'vector' was not declared in this scope
   20 |   vector <char> dd = {'A', 'B', 'X', 'Y'};
      |   ^~~~~~
combo.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include "combo.h"
  +++ |+#include <vector>
    2 | using namespace std;
combo.cpp:20:11: error: expected primary-expression before 'char'
   20 |   vector <char> dd = {'A', 'B', 'X', 'Y'};
      |           ^~~~
combo.cpp:22:9: error: 'dd' was not declared in this scope
   22 |     if (dd[i] == x) {
      |         ^~
combo.cpp:29:28: error: 'dd' was not declared in this scope
   29 |     string f1 = ret; f1 += dd[0]; f1 += dd[0];
      |                            ^~
combo.cpp:44:26: error: 'dd' was not declared in this scope
   44 |     string u = ret; u += dd[i];
      |                          ^~