Submission #1043129

#TimeUsernameProblemLanguageResultExecution timeMemory
1043129thatsgonzalezCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h"

#include "bits/stdc++.h"

using namespace std;

int press(string p){
  int len = p.size();
  int coins = 0;
  for (int i = 0, j = 0; i < len; ++i) {
    if (j < n && S[j] == p[i]) {
      ++j;
    } else if (S[0] == p[i]) {
      j = 1;
    } else {
      j = 0;
    }
    coins = std::max(coins, j);
  }
  return coins;

}

std::string guess_sequence(int N) {
  std::string p = "";
  
  int k = 0;

  n = N;

  int res = press("AB");
  if(res){
    res = press("A");
    if(res) p+="A";
    else p+="B";
  }
  else{
    res = press("X");
    if(res) p+="X";
    else p+="Y";
  }
  k++;

  vector<string> aux;
  
  if(p != "A") aux.push_back("A");
  if(p != "B") aux.push_back("B");
  if(p != "X") aux.push_back("X");
  if(p != "Y") aux.push_back("Y");

  for(int i = 1; i<N-1; i++){

    string query = p+aux[0]+p+(aux[1]+aux[0])+p+(aux[1]+aux[1])+p+(aux[1]+aux[2]);

    res = press(query);

    if(res-k == 2){
      p+=aux[1];
    }
    else if(res-k == 1){
      p+=aux[0];
    }
    else{
      p+=aux[2];
    }

    k++;


  }

  res = press(p + aux[0]);
  if(res-k) p += aux[0];
  else{
    res = press(p+aux[1]);
    if(res-k) p+=aux[1];
    else p+=aux[2];
  }

  return p;
}

Compilation message (stderr)

combo.cpp: In function 'int press(std::string)':
combo.cpp:11:13: error: 'n' was not declared in this scope
   11 |     if (j < n && S[j] == p[i]) {
      |             ^
combo.cpp:11:18: error: 'S' was not declared in this scope
   11 |     if (j < n && S[j] == p[i]) {
      |                  ^
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:3: error: 'n' was not declared in this scope
   29 |   n = N;
      |   ^