Submission #699917

#TimeUsernameProblemLanguageResultExecution timeMemory
699917elkernos콤보 (IOI18_combo)C++17
5 / 100
1 ms208 KiB
#include "combo.h"
#include "bits/stdc++.h"

using namespace std;

string guess_sequence(int N)
{
    string s = "";
    string maybe = "ABXY";
    auto guess_one = [&]() {
        if (press("AB")) {
            if (press("A")) s = "A";
            else s = "B";
        }
        else {
            if (press("X")) s = "X";
            else s = "Y";
        }
    };
    guess_one(); // 2 zap
    string xdd = "";
    for (auto x : maybe)
        if (x != s[0]) xdd += x;
    maybe = xdd;
    while (size(s) < N - 1) { // n - 3 zap
        string pyt = s + maybe[0] + s + maybe[1] + maybe[0] + s + maybe[1] + maybe[1] + s + maybe[1] + maybe[2];
        int odp = press(pyt);
        if (odp == size(s)) s += maybe[2];
        else if (odp == size(s) + 1) s += maybe[0];
        else s += maybe[1];
    }
    mt19937 gen(32173);
    shuffle(maybe.begin(), maybe.end(), gen);
    if (press(s + maybe[0]) > size(s)) s += maybe[0]; // 2 zap
    else if (press(s + maybe[1]) > size(s)) s += maybe[1];
    else s += maybe[2];
    return s;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     while (size(s) < N - 1) { // n - 3 zap
      |            ~~~~~~~~^~~~~~~
combo.cpp:28:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         if (odp == size(s)) s += maybe[2];
      |             ~~~~^~~~~~~~~~
combo.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         else if (odp == size(s) + 1) s += maybe[0];
      |                  ~~~~^~~~~~~~~~~~~~
combo.cpp:34:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     if (press(s + maybe[0]) > size(s)) s += maybe[0]; // 2 zap
      |         ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
combo.cpp:35:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     else if (press(s + maybe[1]) > size(s)) s += maybe[1];
      |              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...