Submission #154038

#TimeUsernameProblemLanguageResultExecution timeMemory
154038mohamedsobhi777콤보 (IOI18_combo)C++14
10 / 100
89 ms536 KiB
#include "combo.h"

using namespace std;

std::string guess_sequence(int N) {
    string ret = "";
    string chs = "ABXY";
    for(int i = 0;i<3;i++)
    {
        if(press( string(1 , chs[i] ) ))
        {
            ret+=chs[i];
            break;
        }
    }
    if(!ret.size())
        ret+=chs[3];

    for(int i = 1;i<N;i++)
    {
        bool ok = 0;
        for(int j = 0;j<3;j++)
        {
            string ask = ret;
            ask+=chs[j];
            if( press( ask ) ==i+1 )
            {
                ret+=chs[j];
                ok = 1;
                break;
            }
        }
        if(ret.size()==i)
            ret+=chs[3];
    }
    return ret;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |         if(ret.size()==i)
      |            ~~~~~~~~~~^~~
combo.cpp:21:14: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   21 |         bool ok = 0;
      |              ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...