Submission #200029

#TimeUsernameProblemLanguageResultExecution timeMemory
200029mohamedsobhi777Combo (IOI18_combo)C++14
0 / 100
36 ms276 KiB
#include "combo.h"

using namespace std;

std::string guess_sequence(int N) {
    string ret = "";
    string chs = "ABXY";

    if( press("XY") )
    {
        if(press("X"))ret = "X" , chs = "ABY";
        else ret = "Y" , chs = "ABX";
    }
    else
    {
        if(press("A"))ret = "A" , chs = "BXY";
        else ret = "B" , chs ="AXY";
    }

    for(int i = 1;i<N;i+=2)
    {
        if(i+1==N)
        {
            string ask1 = ret;ask1+=chs[0];
            string ask2 = ret;ask2+=chs[1];
            string ask3 = ret;ask3+=chs[2];
            if(press(ask1) ==i+1 )ret = ask1;
            else if(press(ask2) ==i+1 )ret = ask2;
            else ret = ask3;
        }
        else
        {
            string ask1 = ret ;
            ask1+=chs[0];

            ask1+=ret;
            ask1+=chs[1];

            ask1+=ret;
            ask1+=chs[0];
            ask1+=chs[1];

            ask1+=ret;
            ask1+=chs[1];
            ask1+=chs[0];
            while(ask1.size()> 4*N)
                ;

            int ans =press(ask1);
            if(ans==i)
            {
                ret+=chs[2];
                i--;
            }
            else if(ans==i+1)
            {
                string ask2 = ret;ask2+=chs[0];
                if( press(ask2)==i+1 )
                    ret+=chs[0];
                else ret+=chs[1];
                i--;
            }
            else
            {
                string ask2 = ret ;
                ask2+=chs[0];
                if( press(ask2)==i+1 )
                {
                    ret+=chs[0];
                    ret+=chs[1];
                }
                else
                {
                    ret+=chs[1];
                    ask2+=chs[0];
                }
            }
        }

    }
    return ret;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:46:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |             while(ask1.size()> 4*N)
      |                   ~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...