Submission #1227731

#TimeUsernameProblemLanguageResultExecution timeMemory
1227731Tesla89Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h"

using namespace std;

string guess_sequence(int N) {
    string res="";
    char ch[3];
    if(press("AB")>0){
        if(press("A")==1){
            res="A";
            ch = {"B","X","Y"};
        }
        else{
            res="B";
            ch = {"A","X","Y"};
        }
    }
    else if(press("X")==1){
        res="X";
        ch = {"A","B","Y"};
    }
    else{
        res="Y";
        ch = {"A","B","X"};
    }
    string query="";
    int last=1;
    for(int i=1;i<N-1;i++){
        for(int j=0;j<3;j++){
            query+=res+ch[2]+ch[j];
        }
        query+=res+ch[1];
        int response=press(query);
        res+=c[response-last];
        last=response;
        query="";
    }
    query=res+ch[0]+res+ch[1];
    if(press(query)==last)res+=c[2];
    else if(press(res+ch[0])==last)res+=c[1];
    else res+=c[0];
    return res;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:11:16: error: assigning to an array from an initializer list
   11 |             ch = {"B","X","Y"};
      |             ~~~^~~~~~~~~~~~~~~
combo.cpp:15:16: error: assigning to an array from an initializer list
   15 |             ch = {"A","X","Y"};
      |             ~~~^~~~~~~~~~~~~~~
combo.cpp:20:12: error: assigning to an array from an initializer list
   20 |         ch = {"A","B","Y"};
      |         ~~~^~~~~~~~~~~~~~~
combo.cpp:24:12: error: assigning to an array from an initializer list
   24 |         ch = {"A","B","X"};
      |         ~~~^~~~~~~~~~~~~~~
combo.cpp:34:14: error: 'c' was not declared in this scope
   34 |         res+=c[response-last];
      |              ^
combo.cpp:39:32: error: 'c' was not declared in this scope; did you mean 'ch'?
   39 |     if(press(query)==last)res+=c[2];
      |                                ^
      |                                ch
combo.cpp:40:41: error: 'c' was not declared in this scope; did you mean 'ch'?
   40 |     else if(press(res+ch[0])==last)res+=c[1];
      |                                         ^
      |                                         ch
combo.cpp:41:15: error: 'c' was not declared in this scope; did you mean 'ch'?
   41 |     else res+=c[0];
      |               ^
      |               ch