Submission #112453

#TimeUsernameProblemLanguageResultExecution timeMemory
112453sochoCombo (IOI18_combo)C++14
5 / 100
41 ms348 KiB
#include <bits/stdc++.h>
using namespace std;
#include "combo.h"

string guess_sequence(int N) {

    int ab = press("AB");
    string pref = "";
    string rem;
    if (ab > 0) {
        // a or b
        int a = press("A");
        if (a > 0) {
            pref = "A";
            rem = "BXY";
        }
        else {
            pref = "B";
            rem = "AXY";
        }
    }
    else {
        int a = press("X");
        if (a > 0) {
            pref = "X";
            rem = "ABY";
        }
        else {
            pref = "Y";
            rem = "ABX";
        }
    }
    if (N==1) return pref;
    for (int i=1; i<N-1; i++) {
        string q = pref + rem[0] + pref + rem[1] + rem[0] + pref + rem[1] + rem[1] + pref + rem[1] + rem[2];
        int p = press(q);
        if (p == pref.size()) {
            pref += rem[2];
        }
        else if (p == pref.size() + 1) {
            pref += rem[0];
        }
        else {
            pref += rem[1];
        }
    }
    string q = pref + rem[0] + pref + rem[1];
    int res = press(q);
    if (res == pref.size()) {
        pref += rem[2];
    }
    else {
        string q2 = pref + rem[0];
        int res2 = press(q2);
        if (res2 == pref.size()) {
            pref += rem[1];
        }
        else {
            pref += rem[0];
        }
    }
    return pref;

}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if (p == pref.size()) {
      |             ~~^~~~~~~~~~~~~~
combo.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         else if (p == pref.size() + 1) {
      |                  ~~^~~~~~~~~~~~~~~~~~
combo.cpp:49:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     if (res == pref.size()) {
      |         ~~~~^~~~~~~~~~~~~~
combo.cpp:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         if (res2 == pref.size()) {
      |             ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...