Submission #107152

#TimeUsernameProblemLanguageResultExecution timeMemory
107152nickyrioCombo (IOI18_combo)C++17
100 / 100
64 ms608 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int N) {
    string st;
    vector<char> Char = {'A', 'B', 'X', 'Y'};
    if (press("AB") > 0) {
        if (press("A")) st = "A";
        else st = "B";
    } else {
        if (press("X")) st = "X";
        else st = "Y";
    }
    for (int i = 0; i < 4; ++i) if (Char[i] == st[0]) {
        Char.erase(Char.begin() + i);
    }

    for (int i = 1; i < N - 1; ++i) {
        string p = st + Char[0];
        for (int j = 0; j < 3; ++j) p = p + st + Char[1] + Char[j];
        int res = press(p);
        if (res == st.size()) {
            st.push_back(Char[2]);
        } else {
            if (res == st.size() + 1) {
                st.push_back(Char[0]);
            } else st.push_back(Char[1]);
        }
    }
    if (N > 1) {
        if (press(st + Char[0]) == N) {
            return st + Char[0];
        }    
        if (press(st + Char[1]) == N) {
            return st + Char[1];
        }    
        return st + Char[2];
    }
    return st;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if (res == st.size()) {
      |             ~~~~^~~~~~~~~~~~
combo.cpp:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             if (res == st.size() + 1) {
      |                 ~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...