Submission #296991

#TimeUsernameProblemLanguageResultExecution timeMemory
296991TouubsCombo (IOI18_combo)C++17
97 / 100
34 ms508 KiB
#include "combo.h" using namespace std; string keys; char initKey; std::string guess_sequence(int N) { if (press("A")) { keys = "BXY"; initKey = 'A'; } else if (press("B")) { keys = "AXY"; initKey = 'B'; } else if (press("X")) { keys = "ABY"; initKey = 'X'; } else { keys = "ABX"; initKey = 'Y'; } string sol = {initKey}; for (int i = 1; i < N-1; i++) { string q; q += sol; q += {keys[0]}; for (char ot : keys) { q += sol; q += {keys[1], ot}; } int res = press(q); if (res == sol.size() + 1) sol.push_back(keys[0]); else if (res == sol.size() + 2) sol.push_back(keys[1]); else sol.push_back(keys[2]); } if (N > 1) { if (press(sol + (string(1, keys[0]))) == N) sol.push_back(keys[0]); else if (press(sol + string(1, keys[1])) == N) sol.push_back(keys[1]); else sol.push_back(keys[2]); } return sol; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  if (res == sol.size() + 1) sol.push_back(keys[0]);
      |      ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:35:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  else if (res == sol.size() + 2) sol.push_back(keys[1]);
      |           ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...