Submission #1364566

#TimeUsernameProblemLanguageResultExecution timeMemory
1364566paskalisapoCombo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;

string guess_sequence(int N){
    char first;
    if(press("AB") > 0) {
        if(press("A") > 0) {
            first = 'A';
        }
        else {
            first = 'B';
        }
    }
    else {
        if(press("X") > 0){
            first = 'X';
        }
        else{
            first = 'Y';
        }
    }
    string curpref ;
    curpref += first;
    vector<char> not_first;

    if(first != 'A'){
        not_first.push_back('A');
    }
    if(first != 'B'){
        not_first.push_back('B');
    }
    if(first != 'X'){
        not_first.push_back('X');
    }
    if(first != 'Y'){
        not_first.push_back('Y');
    }

    for(int pos = 2; pos <= N - 1; pos++){
        
        //return pos if it is 0
        string ask = curpref;
        ask += not_first[0];

        //return pos + 1 if it is 1
        ask += curpref;
        ask += not_first[1];
        ask += not_first[2];
        ask += curpref;
        ask += not_first[1];
        ask += not_first[1];
        ask += curpref;
        ask += not_first[1];
        ask += not_first[0];

        //return pos - 1 if it is 2

        int pressans = press(ask);
        if(pressans == pos){
            curpref += not_first[0];
        }
        else if(pressans == pos + 1){
            curpref += not_first[1];
        }
        else {
            curpref += not_first[2];
        }
    }
    if(n == 1){
        return curpref;
    }
    if(press(curpref + not_first[0]) == N) {
        curpref += not_first[0];
    }
    else if(press(curpref + not_first[1]) == N) {
        curpref += not_first[1];
    }
    else {
        curpref += not_first[2];
    }

    return curpref;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:70:8: error: 'n' was not declared in this scope
   70 |     if(n == 1){
      |        ^