Submission #501327

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


string guess_sequence(int N){
    string a;
    string ex;
    for(int i=0;i<N;i++){
        if(i==0){
            if(press("AB")){
                if(press("A")){
                    a+="A";
                    ex="BXY";
                }
                else {
                    a+="B";
                    ex="AXY";
                }
            }
            else if(press("X")){
                a+="X";
                ex="ABY";
            }
            else {
                a+="Y";
                ex+="ABX";
            }

        }
        else if(i==N-1){
            if(press(a+ex[0])){a+=ex[0];}
            else if(press(ex[1])){a+=ex[1];}
            else {a+=ex[2];}
        }
        else{
            int p=press(a+ex[0]+ex[0]+a+ex[0]+ex[1]+a+ex[0]+ex[2]+a+ex[1]);
            if(p==2){a+=ex[0];}
            else if(p==1){a+=ex[1];}
            else {a+=ex[2];}
        }
    }
    return a;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:32: error: could not convert 'ex.std::__cxx11::basic_string<char>::operator[](1)' from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   33 |             else if(press(ex[1])){a+=ex[1];}
      |                                ^
      |                                |
      |                                __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}