Submission #107241

#TimeUsernameProblemLanguageResultExecution timeMemory
107241wonyoungCombo (IOI18_combo)C++14
10 / 100
77 ms436 KiB
#include <iostream>
#include <string>

using namespace std;
int press(string p);
string guess_sequence(int N)
{
    const char buttons[4] = { 'A', 'B', 'X', 'Y' };
    string s = "";
    int i;
    while (s.length() < N)
    {
        for (i=0; i<3; i++)
        {
            if (s.length() > 0 && s[0] == buttons[i])
                continue;
            string query_string = "";
            query_string.append(s);
            query_string.push_back(buttons[i]);
            int n = press(query_string);
            if (n > s.length())
            {
                break;
            }
        }
        s.push_back(buttons[i]);
    }

    return s;
}

Compilation message (stderr)

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