Submission #831378

#TimeUsernameProblemLanguageResultExecution timeMemory
831378MularstyleCombo (IOI18_combo)C++14
100 / 100
27 ms536 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;


std::string guess_sequence(int n) {

    string S;
    string a;

    ///FIRST DIGIT
    if(press("AB")>0){
        if(press("A")>0)
            S="A",a="BXY";
        else
            S="B",a="AXY";
    }
    else{
        if(press("X")>0)
            S="X",a="ABY";
        else
            S="Y",a="ABX";
    }
    if(n==1)
        return S;

    ///MIDDLE
    int cur=1;
    while(S.length()<n-1)
    {
        int t=press(S+a[0]+S+a[1]+a[0]+S+a[1]+a[1]+S+a[1]+a[2]);
        if(t==cur+1)
            S+=a[0];
        else if(t==cur+2)
            S+=a[1];
        else
            S+=a[2];
        cur++;
    }

    ///FIND LAST DIGIT
    if(press(S+"A"+S+"B")==n)
    {
        if(press(S+"A")==n)
            S+="A";
        else
            S+="B";
    }
    else
    {
        if(press(S+"X")==n)
            S+="X";
        else
            S+="Y";
    }
    return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     while(S.length()<n-1)
      |           ~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...