Submission #832721

#TimeUsernameProblemLanguageResultExecution timeMemory
832721kamelfanger83Combo (IOI18_combo)C++17
0 / 100
0 ms208 KiB
#include <iostream> #include <vector> #include <string> #include "combo.h" using namespace std; /*int press(string s){ cout << s << endl; int ans; cin >> ans; return ans; }*/ 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:24:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     while (res.size() < N - 1){
      |            ~~~~~~~~~~~^~~~~~~
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 (ans == res.size()) res += 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 |         else if (ans == res.size() + 1) {
      |                  ~~~~^~~~~~~~~~~~~~~~~
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[0] + lchars[2];
      |                 ~~~~~^~~~~~~~~~~~~
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[1] + lchars[2];
      |                      ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:35:22: 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 (sans == res.size()) res += lchars[1] + lchars[0];
      |                 ~~~~~^~~~~~~~~~~~~
combo.cpp:36:27: 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 (sans == res.size() + 1) res += lchars[0] + lchars[1];
      |                      ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:40:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     if (res.size() == N - 1){
      |         ~~~~~~~~~~~^~~~~~~~
combo.cpp:41:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if (press(res + lchars[0]) > res.size()) res += lchars[0];
      |             ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:42:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         else if (press(res + lchars[1]) > res.size()) res += lchars[1];
      |                  ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...