Submission #1355395

#TimeUsernameProblemLanguageResultExecution timeMemory
1355395seasonzCombo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h"
using namespace std;
char find_first()
{
  if (press("AB"))
  {
    if (press("A")) return 'A';
    else return 'B';
  }
  else
  {
    if (press("X")) return 'X';
    else return 'Y';
  }
}
void add_next(string &cur, vector<char> &avail, int &now, int N);
{
  if (cur.size() == N) return;
  string ttry = cur + avail[0] + avail[0] + cur + avail[0] + avail[1] + cur + avail[1];
  int out = press(ttry);
  if (out - now == 2) cur += avail[0];
  else if (out - now == 1) cur += avail[1];
  else cur += avail[2];
  now++;
  add_next(cur, avail, now, N);
}
string guess_sequence(int N) {
  vector<char> vv = {'A', 'B', 'X', 'Y'};
  vector<char> avail;
  char first = find_first();
  for (char ch : vv) if (ch != first) avail.push_back(ch);
  string cur = "";
  int now = 0;
  add_next(cur, avail, now, N);
  return cur;
}

Compilation message (stderr)

combo.cpp:16:28: error: 'vector' has not been declared
   16 | void add_next(string &cur, vector<char> &avail, int &now, int N);
      |                            ^~~~~~
combo.cpp:16:34: error: expected ',' or '...' before '<' token
   16 | void add_next(string &cur, vector<char> &avail, int &now, int N);
      |                                  ^
combo.cpp:17:1: error: expected unqualified-id before '{' token
   17 | {
      | ^
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:3: error: 'vector' was not declared in this scope
   28 |   vector<char> vv = {'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:28:10: error: expected primary-expression before 'char'
   28 |   vector<char> vv = {'A', 'B', 'X', 'Y'};
      |          ^~~~
combo.cpp:29:10: error: expected primary-expression before 'char'
   29 |   vector<char> avail;
      |          ^~~~
combo.cpp:31:18: error: 'vv' was not declared in this scope
   31 |   for (char ch : vv) if (ch != first) avail.push_back(ch);
      |                  ^~
combo.cpp:31:39: error: 'avail' was not declared in this scope
   31 |   for (char ch : vv) if (ch != first) avail.push_back(ch);
      |                                       ^~~~~
combo.cpp:34:17: error: 'avail' was not declared in this scope
   34 |   add_next(cur, avail, now, N);
      |                 ^~~~~