Submission #216633

#TimeUsernameProblemLanguageResultExecution timeMemory
216633achvanovCombo (IOI18_combo)C++17
5 / 100
1 ms200 KiB
#include <bits/stdc++.h>
#include <combo.h>

using namespace std;

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

string guess_sequence(int n) {
  string res = "";
  for (int k = 0; k < 4; ++k) {
    res.clear();
    res += c[k];
    for (int i = 1; i < n; ++i) {
      bool ok = false;
      for (int j = 0; j < 4; ++j) {
        if (k != j and press(res + c[j]) > res.size()) {
          res += c[j];
          ok = true;
          break;
        }
      }
      if (!ok) {
        break;
      }
    }
    if (res.size() == n) {
      return res;
    }
  }
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:16:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         if (k != j and press(res + c[j]) > res.size()) {
      |                        ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:26:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     if (res.size() == n) {
      |         ~~~~~~~~~~~^~~~
combo.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...