Submission #832771

#TimeUsernameProblemLanguageResultExecution timeMemory
832771kamelfanger83Combo (IOI18_combo)C++14
100 / 100
25 ms464 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(string({c})); while (res.size() < N - 1){ 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]; else if (ans == res.size() + 1) { int sans = press(res + lchars[1] + lchars[1]); if (sans == res.size()) res += lchars[0] + lchars[2]; else 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]; else if (sans == res.size() + 1) res += lchars[0] + lchars[1]; else res += lchars[0] + lchars[0]; } } if (res.size() == N - 1){ if (press(res + lchars[0]) > res.size()) res += lchars[0]; else if (press(res + lchars[1]) > res.size()) res += lchars[1]; else res += lchars[2]; } 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 - 1){
      |            ~~~~~~~~~~~^~~~~~~
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: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 |         else 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:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             else 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:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             else if (sans == res.size() + 1) res += lchars[0] + lchars[1];
      |                      ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:34:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     if (res.size() == N - 1){
      |         ~~~~~~~~~~~^~~~~~~~
combo.cpp:35:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if (press(res + lchars[0]) > res.size()) res += lchars[0];
      |             ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:36:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         else if (press(res + lchars[1]) > res.size()) res += lchars[1];
      |                  ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...