Submission #95638

#TimeUsernameProblemLanguageResultExecution timeMemory
95638rocketninja7Combo (IOI18_combo)C++14
5 / 100
2 ms200 KiB
#include "combo.h"

std::string guess_sequence(int N) {
    std::string p = "";
    int coinsAB = press("AB");
    char buttons[3];
    std::string S = "";
    if(coinsAB>=1){
        int coinsA=press("A");
        if(coinsA==1){
            S+='A';
            buttons[0]='B';
            buttons[1]='X';
            buttons[2]='Y';
        }
        else{
            S+='B';
            buttons[0]='A';
            buttons[1]='X';
            buttons[2]='Y';
        }
    }
    else{
        int coinsX=press("X");
        if(coinsX==1){
            S+='X';
            buttons[0]='A';
            buttons[1]='B';
            buttons[2]='Y';
        }
        else{
            S+='Y';
            buttons[0]='A';
            buttons[1]='B';
            buttons[2]='X';
        }
    }
    while(S.length()<N-1){
        p=S+buttons[0]+buttons[0]+S+buttons[0]+buttons[1]+S+buttons[0]+buttons[2]+S+buttons[1];
        int temp=press(p);
        if(temp==S.length()+2){
            S+=buttons[0];
        }
        else if(temp==S.length()+1){
            S+=buttons[1];
        }
        else{
            S+=buttons[2];
        }
    }
    if(press(S+buttons[0])==S.length()+1){
        S+=buttons[0];
    }
    else if(press(S+buttons[1])==S.length()+1){
        S+=buttons[1];
    }
    else{
        S+=buttons[2];
    }
    return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |     while(S.length()<N-1){
      |           ~~~~~~~~~~^~~~
combo.cpp:41:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if(temp==S.length()+2){
      |            ~~~~^~~~~~~~~~~~~~
combo.cpp:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         else if(temp==S.length()+1){
      |                 ~~~~^~~~~~~~~~~~~~
combo.cpp:51:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     if(press(S+buttons[0])==S.length()+1){
      |        ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:54:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     else if(press(S+buttons[1])==S.length()+1){
      |             ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...