Submission #1045485

#TimeUsernameProblemLanguageResultExecution timeMemory
1045485SiliconSquaredCombo (IOI18_combo)C++17
100 / 100
19 ms1796 KiB
#include "combo.h"
using namespace std;

std::string guess_sequence(int n) {
    string z;
    int x;
    string a,b,c,d;
    if (press("AB")>0){
        if (press("A")==1){
            a="A";b="B";
        }else{
            a="B";b="A";
        }
        c="X";d="Y";
    }else{
        if (press("X")==1){
            a="X";b="Y";
        }else{
            a="Y";b="X";
        }
        c="A";d="B";
    }
    z=a;
    if (n==1){return z;}
    
    while (z.length()<n-1){
        x=press(z+b+z+c+b+z+c+c+z+c+d);
        if (x==z.length()){
            z+=d;
        }else if (x==z.length()+1){
            z+=b;
        }else{
            z+=c;
        }
    }
    if (press(z+b)==n){
        return z+b;
    }else if (press(z+c)==n){
        return z+c;
    }else{
        return z+d;
    }
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     while (z.length()<n-1){
      |            ~~~~~~~~~~^~~~
combo.cpp:28:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         if (x==z.length()){
      |             ~^~~~~~~~~~~~
combo.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         }else if (x==z.length()+1){
      |                   ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...