Submission #786582

#TimeUsernameProblemLanguageResultExecution timeMemory
786582JoenPoenManCombo (IOI18_combo)C++17
100 / 100
29 ms528 KiB


#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;

vector<char> chars = {'X', 'Y', 'A', 'B'};

string Sol;

std::string guess_sequence(int N) {
    if (press("AB") >= 1) Sol = (press("A") ? "A" : "B");
    else Sol = (press("X") ? "X" : "Y");
    chars.erase(find(chars.begin(), chars.end(), Sol[0]));

    for (int i = 1; i < N-1; i++) {
        string inp;
        inp = Sol + chars[0];
        inp += Sol + chars[1] + chars[0];
        inp += Sol + chars[1] + chars[1];
        inp += Sol + chars[1] + chars[2];
        int res = press(inp);
        if (res == Sol.length()) Sol.push_back(chars[2]);
        else if (res == Sol.length()+1) Sol.push_back(chars[0]);
        else Sol.push_back(chars[1]);
    }
    if (N > 1) {
        string inp;
        inp = Sol + chars[0] + Sol + chars[1];
        if (press(inp) == Sol.length()) Sol.push_back(chars[2]);
        else {
            inp = Sol + chars[0];
            if (press(inp) == Sol.length()) Sol.push_back(chars[1]);
            else Sol.push_back(chars[0]);
        } 
    }

    return Sol;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if (res == Sol.length()) Sol.push_back(chars[2]);
      |             ~~~~^~~~~~~~~~~~~~~
combo.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         else if (res == Sol.length()+1) Sol.push_back(chars[0]);
      |                  ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if (press(inp) == Sol.length()) Sol.push_back(chars[2]);
      |             ~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:36:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             if (press(inp) == Sol.length()) Sol.push_back(chars[1]);
      |                 ~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...