Submission #383737

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

string guess_sequence(int n){
    string CH = "AB" ; 
    int anss = press(CH) ;
    if(anss==0) CH="XY" ;
    char s ;  
    string DUMB; 
    DUMB+=CH[0] ; 
        if(press(DUMB)) s=CH[0]; 
        else s=CH[1]; 
    string BUTTONS = "ABXY" ; 
    for(int i=0;i<BUTTONS.size();i++){
        if(BUTTONS[i]==s){
            BUTTONS.erase(BUTTONS.begin()+i) ; 
            break ; 
        }
    }//YXXBA
    string ans ; 
    ans+=s ; 
    for(int i=1;i+1<n;i++){
        string ask = ans; 
        ask+=BUTTONS[0] ; 
        for(int j=0;j<3;j++){
            ask+=ans; 
            ask+=BUTTONS[1];
            ask+=BUTTONS[j];
        }
        int res = press(ask) ; 
        if(res==i+1){
            ans+=BUTTONS[0];             
        }
        else if(res>i+1){
            ans+=BUTTONS[1]; 
        }
        else{
            ans+=BUTTONS[2]; 
        }
    }   
    string ask ; 
    ask=ans ; 
    ask+=BUTTONS[0] ; 
    if(press(ask)==n){
        return ask ; 
    }
    ask.pop_back() ; 
    ask+=BUTTONS[1] ; 
    if(press(ask)==n){
        return ask ; 
    }
    ans+=BUTTONS[2]; 
    return ans ; 
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:16: error: 'press' was not declared in this scope
    6 |     int anss = press(CH) ;
      |                ^~~~~
combo.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0;i<BUTTONS.size();i++){
      |                 ~^~~~~~~~~~~~~~~