Submission #107240

#TimeUsernameProblemLanguageResultExecution timeMemory
107240wonyoungCombo (IOI18_combo)C++14
10 / 100
91 ms424 KiB
#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++)
        {
            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:10:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 |     while (s.length() < N)
      |            ~~~~~~~~~~~^~~
combo.cpp:18:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |             if (n > s.length())
      |                 ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...