Submission #400128

#TimeUsernameProblemLanguageResultExecution timeMemory
400128luisgalanCombo (IOI18_combo)C++14
30 / 100
82 ms444 KiB
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
#define debug(x) cerr << #x << " = " << (x) << endl

char chars[4] = {'A', 'B', 'X', 'Y'};
string guess_sequence(int N) {
    string res = "";
    char init;

    if (press("AB")) {
        init = press("A") ? 'A' : 'B';
    } else {
        init = press("X") ? 'X' : 'Y';
    }
    res += init;

    vector<char> others;
    for (int i = 0; i < 4; i++) {
        if (chars[i] == init) continue;
        others.push_back(chars[i]);
    }
    // debug(others[0]);
    // debug(others[1]);
    // debug(others[2]);

    while (res.size() < N) {
        // cerr << res << endl;
        if (press(res + others[0]) > res.size()) {
            res += others[0];
        } else if (press(res + others[1]) > res.size()) {
            res += others[1];
        } else {
            res += others[2];
        }
    }
    // cerr << res << endl;
    return res;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     while (res.size() < N) {
      |            ~~~~~~~~~~~^~~
combo.cpp:29:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         if (press(res + others[0]) > res.size()) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:31:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         } else if (press(res + others[1]) > res.size()) {
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...