제출 #1217967

#제출 시각아이디문제언어결과실행 시간메모리
1217967islam_2010콤보 (IOI18_combo)C++20
컴파일 에러
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;
}

컴파일 시 표준 에러 (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];
      |                           ^