Submission #1008375

#TimeUsernameProblemLanguageResultExecution timeMemory
1008375HappyCapybaraCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

string guess_sequence(int N){
    string s;
    if (press("AB")){
        if (press("A")) s = "A";
        else s = "B";
    }
    else {
        if (press("X")) s = "X";
        else s = "Y";
    }
    vector<string> v;
    for (string x : {"A", "B", "X", "Y"}) if (s != x) v.push_back(x);
    while (s.size() < N-1){
        string p;
        p += s;
        p += v[0];
        for (int i=0; i<3; i++){
            p += s;
            p += v[1];
            p += v[i];
        }
        int res = press(p);
        if (res == s.size()+1) s += v[0];
        else if (res == s.size()+2) s += v[1];
        else s += v[2];
    }
    if (press(s+v[0]) == N) return s+v[0];
    if (press(s+v[1]) == N) return s+v[1];
    else return s+v[2];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:9: error: 'press' was not declared in this scope
    6 |     if (press("AB")){
      |         ^~~~~
combo.cpp:16:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |     while (s.size() < N-1){
      |            ~~~~~~~~~^~~~~
combo.cpp:25:19: error: 'press' was not declared in this scope; did you mean 'res'?
   25 |         int res = press(p);
      |                   ^~~~~
      |                   res
combo.cpp:26:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if (res == s.size()+1) s += v[0];
      |             ~~~~^~~~~~~~~~~~~
combo.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         else if (res == s.size()+2) s += v[1];
      |                  ~~~~^~~~~~~~~~~~~
combo.cpp:30:9: error: 'press' was not declared in this scope
   30 |     if (press(s+v[0]) == N) return s+v[0];
      |         ^~~~~
combo.cpp:31:9: error: 'press' was not declared in this scope
   31 |     if (press(s+v[1]) == N) return s+v[1];
      |         ^~~~~
combo.cpp:5:12: warning: control reaches end of non-void function [-Wreturn-type]
    5 |     string s;
      |            ^