Submission #1217967

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

int press(string s);

string guess_sequence(int n) {
    string s;

    if(press("AB")){
        if(press("A")){
            s = 'A';
            string a[4] = {"BB", "BX", "BY", "X"};
        }else {
            s='B';
            string a[4] = {"AA", "AX", "AY", "B"};
        }
    }else {
        if(press("X")){
            s = 'X';
            string a[4] = {"BB", "BX", "BY", "X"};
        }else {
            s = 'Y';
            string a[4] = {"BB", "BX", "BY", "X"};
        }
    }if(n==1){
        return s;
    }
    for(int i = 1; i < n-1; i++){
        if(s[0]=='A'){
            string ns = s+a[0]+s+a[1]+s+a[2]+s+a[3];
            int x = press(ns);
            if(x==s.size()){
                s+='Y';
            }else if(x == s.size()+1){
                s+='X';
            }else {
                s+='B';
            }
        }
    }return s;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:27: error: 'a' was not declared in this scope
   30 |             string ns = s+a[0]+s+a[1]+s+a[2]+s+a[3];
      |                           ^