Submission #154065

#TimeUsernameProblemLanguageResultExecution timeMemory
154065nthoangCombo (IOI18_combo)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

#ifndef LOCAL
#include "combo.h"
#endif

#ifdef LOCAL
#include "/Users/nth842002/Library/debug.h"
int press(string p) { }
int main() { }
#endif

using namespace std;

const string moves = "ABXY";

string guess_sequence(int n) {
  srand(time(0));
  string s;
  for (int i = 0; i < 3; i++) {
    s += moves[i];
    if (press(s) == 1) {
      break;
    }
    s.pop_back();
  }
  if (s.empty()) {
    s += moves[3];
  }
  vector<string> avail(n);
  for (int i = 0; i < 4; i++) {
    if (moves[i] != s[0]) {
      avail[0] += moves[i];
    }
  }
  for (int i = 1; i < n; i++) {
    avail[i] = avail[0];
    assert((int) avail[i].size() == 3);
    random_shuffle(avail[i].begin(), avail[i].end());
  }
  for (int i = 1; i < n; i++) {
    s += avail[i][0];
    int t = press(s);
    if (t == i - 1) {
      s[i - 1] = avail[i - 1][2];
    } else if (t == i) {
      s[i] = avail[i][1];
    }
  }
  if (press(s) != n) {
    s[n - 1] = avail[i][2];
  }
  assert((int) s.size() == n);
  return s;
}

/* Subtask: q <= 2N + 1

string guess_sequence(int n) {
  srand(time(0));
  string s;
  for (int i = 0; i < 3; i++) {
    string t;
    t += moves[i];
    if (press(t) == 1) {
      s += moves[i];
      break;
    }
  }
  if (s.empty()) {
    s += moves[3];
  }
  string avail;
  for (int i = 0; i < 4; i++) {
    if (moves[i] != s[0]) {
      avail += moves[i];
    }
  }
  for (int i = 1; i < n; i++) {
    random_shuffle(avail.begin(), avail.end());
    for (int j = 0; j < 2; j++) {
      s += avail[j];
      if (press(s) == i + 1) {
        break;
      }
      s.pop_back();
    }
    if (s.length() == i) {
      s += avail[2];
    }
  }
  assert((int) s.length() == n);
  return s;
}

*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:51:22: error: 'i' was not declared in this scope
   51 |     s[n - 1] = avail[i][2];
      |                      ^