Submission #124961

#TimeUsernameProblemLanguageResultExecution timeMemory
124961teomrnCombo (IOI18_combo)C++14
5 / 100
3 ms212 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string get_begin() { if (press("AB") >= 1) { if (press("A")) return "ABXY"; return "BAXY"; } if (press("X")) return "XABY"; return "YABX"; } string guess_sequence(int N) { string order = get_begin(); string S = order.substr(0, 1); string oth1 = order.substr(1, 1); string oth2 = order.substr(2, 1); string oth3 = order.substr(3, 1); while (S.size() <= N - 2) { /// mai pot adauga 2 chestii string query = S + oth1 + oth1 + S + oth1 + oth2 + S + oth1 + oth3 + S + oth2; int ans = press(query); if (ans == S.size() + 2) S += oth1; else if (ans == S.size() + 1) S += oth2; else S += oth3; } if (S.size() != N) { if (press(S + oth1 + S + oth2) == N) { if (press(S + oth1) == N) S += oth1; else S += oth2; } else S += oth3; } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:18: 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 (S.size() <= N - 2) {
      |         ~~~~~~~~~^~~~~~~~
combo.cpp:28:11: 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 (ans == S.size() + 2)
      |       ~~~~^~~~~~~~~~~~~~~
combo.cpp:30:16: 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 (ans == S.size() + 1)
      |            ~~~~^~~~~~~~~~~~~~~
combo.cpp:36:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |  if (S.size() != N) {
      |      ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...