Submission #562429

# Submission time Handle Problem Language Result Execution time Memory
562429 2022-05-14T10:30:27 Z 1zaid1 Combo (IOI18_combo) C++17
Compilation error
0 ms 0 KB
#include "combo.h"
using namespace std;
string guess_sequence(int n) {
  vector<string> v = {"A", "B", "X", "Y"};
  string cum = "";

  for (int i = 0; i < 3; i++) {
    if (press(v[i])) {
      swap(v[3], v[i]);
      break;
    }
  }

  cum += v.back();
  v.pop_back();

  for (int k = 2; k <= n; k++) {
    string c = v.back();
    for (int i = 0; i < 2; i++) {
      if (press(cum+v[i]) == k) {
        c = v[i];
        break;
      }
    }

    cum += c;
  }

  return cum;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:4:3: error: 'vector' was not declared in this scope
    4 |   vector<string> v = {"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:4:16: error: expected primary-expression before '>' token
    4 |   vector<string> v = {"A", "B", "X", "Y"};
      |                ^
combo.cpp:4:18: error: 'v' was not declared in this scope
    4 |   vector<string> v = {"A", "B", "X", "Y"};
      |                  ^