Submission #832702

#TimeUsernameProblemLanguageResultExecution timeMemory
832702kamelfanger83Combo (IOI18_combo)C++14
0 / 100
0 ms208 KiB
#include <iostream> #include <vector> #include <string> #include "combo.h" using namespace std; string guess_sequence(int N){ int 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:18:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     while (res.size() < N){
      |            ~~~~~~~~~~~^~~
combo.cpp:20:17: 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 (ans == res.size()) res += lchars[2];
      |             ~~~~^~~~~~~~~~~~~
combo.cpp:21:17: 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 (ans == res.size() + 1) {
      |             ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |             if (sans == res.size()) res += lchars[0] + lchars[2];
      |                 ~~~~~^~~~~~~~~~~~~
combo.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             if (sans == res.size() + 1) res += lchars[1] + lchars[2];
      |                 ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:29:22: 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 (sans == res.size()) res += lchars[1] + lchars[0];
      |                 ~~~~~^~~~~~~~~~~~~
combo.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             if (sans == res.size() + 1) res += lchars[0] + lchars[1];
      |                 ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:17:81: warning: offset '97' outside bounds of constant string [-Warray-bounds]
   17 |     for (auto c : {'a', 'b', 'x', 'y'}) if (c != res[0]) lchars.push_back("" + c);
      |                                                                                 ^
combo.cpp:17:81: warning: offset '97' outside bounds of constant string [-Warray-bounds]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...