Submission #777841

#TimeUsernameProblemLanguageResultExecution timeMemory
777841JoenPoenManCombo (IOI18_combo)C++17
10 / 100
58 ms444 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

char chars[4] = {'X', 'Y', 'A', 'B'};

std::string guess_sequence(int N) {
    string S{};
    char first;
    for (char ch : chars) {
        if (press(S + ch)) {
            S += ch;
            first = ch;
            break;
        }
    }
    for (int i = 1; i < N; i++) {
        for (char ch : chars) if (ch != first) {
            if (press(S + ch) == S.length()+1) {
                S += ch;
                break;
            }
        }
    }

    return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             if (press(S + ch) == S.length()+1) {
      |                 ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:19:31: warning: 'first' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |         for (char ch : chars) if (ch != first) {
      |                               ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...