Submission #75726

#TimeUsernameProblemLanguageResultExecution timeMemory
75726Markomafko972Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h" using namespace std; string guess_sequence(int N) { string sol = ""; vector<char> v; if (press("AB") >= 1) { if (press("A") == 1) sol += 'A'; else sol += 'B'; } else { if (press("X") == 1) sol += 'X'; else sol += 'Y'; } if (N == 1) return sol; if (sol[0] != 'A') v.push_back('A'); if (sol[0] != 'B') v.push_back('B'); if (sol[0] != 'X') v.push_back('X'); if (sol[0] != 'Y') v.push_back('Y'); for (int i = 2; i < N; i ++) { string tren = ""; for (int j = 0; j < v.size(); j ++) { tren += sol + v[0] + v[j]; } tren += sol + v[1]; int t = press(tren); if (t >= i+1) { sol += v[0]; } else if (t == i) { sol += v[1]; } else { sol += v[2]; } } for (int i = 0; i < (int)v.size()-1; i ++) { if (press(sol + v[i]) == N) { return sol + v[i]; } } return sol + v[ (int)v.size()-1 ]; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:5:2: error: 'vector' was not declared in this scope
    5 |  vector<char> v;
      |  ^~~~~~
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:5:9: error: expected primary-expression before 'char'
    5 |  vector<char> v;
      |         ^~~~
combo.cpp:17:21: error: 'v' was not declared in this scope
   17 |  if (sol[0] != 'A') v.push_back('A');
      |                     ^
combo.cpp:18:21: error: 'v' was not declared in this scope
   18 |  if (sol[0] != 'B') v.push_back('B');
      |                     ^
combo.cpp:19:21: error: 'v' was not declared in this scope
   19 |  if (sol[0] != 'X') v.push_back('X');
      |                     ^
combo.cpp:20:21: error: 'v' was not declared in this scope
   20 |  if (sol[0] != 'Y') v.push_back('Y');
      |                     ^
combo.cpp:24:23: error: 'v' was not declared in this scope
   24 |   for (int j = 0; j < v.size(); j ++) {
      |                       ^
combo.cpp:27:17: error: 'v' was not declared in this scope
   27 |   tren += sol + v[1];
      |                 ^
combo.cpp:41:27: error: 'v' was not declared in this scope
   41 |  for (int i = 0; i < (int)v.size()-1; i ++) {
      |                           ^
combo.cpp:47:15: error: 'v' was not declared in this scope
   47 |  return sol + v[ (int)v.size()-1 ];
      |               ^