Submission #1325920

#TimeUsernameProblemLanguageResultExecution timeMemory
1325920x_aCombo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int N) {
  string p = "", s = "";
  int last = 0, x;
  char t = 'x';
  vector<char> A = {'A', 'B', 'X', 'Y'}, c;
  x = press("AB");
  if(x >= 1){
    if(press("A")) s = "A";
    else s = "B";
  }
  else{
    if(press("X")) s = "X";
    else s = "Y";
  }
  if(N == 1) return s;
  for(char x : A) if(x != s[0]) c.push_back(x);
  int last = 1;

  for(int i = 1; i < N - 1; i ++){
    x = press(s + c[0] + s + c[1] + c[0] + s + c[1] + c[1] + s + c[1] + c[2]);
    if(x == last + 1){
      s += c[0];
    }
    else if(x == last + 2){
      s += c[1];
    }
    else{
      s += c[2];
    }
    last ++;
  }
  int cnt = 0;
  for(char x : c){
    if(cnt == 2){
      s += x;
      break;
    }
    if(press(s + x) == last + 1) s += x;
    cnt ++;
  }
  return s;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:7: error: redeclaration of 'int last'
   22 |   int last = 1;
      |       ^~~~
combo.cpp:8:7: note: 'int last' previously declared here
    8 |   int last = 0, x;
      |       ^~~~