Submission #832695

#TimeUsernameProblemLanguageResultExecution timeMemory
832695kamelfanger83Combo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <string> using namespace std; string guess_sequence(int N){ bool f = press("ab"), s = press("ax"); string res; if (f && s) res = "a"; else if (f) res = "b"; else if (s) res = "x"; else res = "y"; vector<string> lchars; for (auto c : {'a', 'b', 'x', 'y'}) if (c != res[0]) lchars.push_back("" + c); while (res.size() < N){ int ans = press(res + lchars[0] + lchars[0] + res + lchars[0] + lchars[1] + res + lchars[1] + lchars[0]); if (ans == res.size()) res += lchars[2]; if (ans == res.size() + 1) { int sans = press(res + lchars[1] + lchars[1]); if (sans == res.size()) res += lchars[0] + lchars[2]; if (sans == res.size() + 1) res += lchars[1] + lchars[2]; else res += lchars[1] + lchars[1]; } else { int sans = press(res + lchars[0] + lchars[0]); if (sans == res.size()) res += lchars[1] + lchars[0]; if (sans == res.size() + 1) res += lchars[0] + lchars[1]; else res += lchars[0] + lchars[0]; } } return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:14: error: 'press' was not declared in this scope
    8 |     bool f = press("ab"), s = press("ax");
      |              ^~~~~
combo.cpp:10:14: error: 's' was not declared in this scope
   10 |     if (f && s) res = "a";
      |              ^
combo.cpp:16:23: 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 (res.size() < N){
      |            ~~~~~~~~~~~^~~
combo.cpp:18:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if (ans == res.size()) res += lchars[2];
      |             ~~~~^~~~~~~~~~~~~
combo.cpp:19:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         if (ans == res.size() + 1) {
      |             ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             if (sans == res.size()) res += lchars[0] + lchars[2];
      |                 ~~~~~^~~~~~~~~~~~~
combo.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             if (sans == res.size() + 1) res += lchars[1] + lchars[2];
      |                 ~~~~~^~~~~~~~~~~~~~~~~
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 |             if (sans == res.size()) res += lchars[1] + lchars[0];
      |                 ~~~~~^~~~~~~~~~~~~
combo.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             if (sans == res.size() + 1) res += lchars[0] + lchars[1];
      |                 ~~~~~^~~~~~~~~~~~~~~~~