Submission #217808

#TimeUsernameProblemLanguageResultExecution timeMemory
217808kkm0476Combo (IOI18_combo)C++11
100 / 100
41 ms644 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string S; if (press("AB")) { if (press("A")) S = "A"; else S = "B"; } else { if (press("X")) S = "X"; else S = "Y"; } while (S.size() < N - 1) { if (S.size() * 4 + 7 >= 4 * N) break; int l; switch (S[0]) { case 'A': l = press(S + "BB" + S + "BX" + S + "BY" + S + "X"); if (l == S.size() + 2) S += "B"; else if (l == S.size() + 1) S += "X"; else S += "Y"; break; case 'B': l = press(S + "AA" + S + "AX" + S + "AY" + S + "X"); if (l == S.size() + 2) S += "A"; else if (l == S.size() + 1) S += "X"; else S += "Y"; break; case 'X': l = press(S + "AA" + S + "AB" + S + "AY" + S + "B"); if (l == S.size() + 2) S += "A"; else if (l == S.size() + 1) S += "B"; else S += "Y"; break; case 'Y': l = press(S + "AA" + S + "AB" + S + "AX" + S + "B"); if (l == S.size() + 2) S += "A"; else if (l == S.size() + 1) S += "B"; else S += "X"; break; } } while (S.size() < N) { if (press(S + "A" + S + "B") == S.size() + 1) { if (press(S + "A") == S.size() + 1) S += "A"; else S += "B"; } else { if (press(S + "X") == S.size() + 1) S += "X"; else S += "Y"; } } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:23:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |     while (S.size() < N - 1)
      |            ~~~~~~~~~^~~~~~~
combo.cpp:25:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |         if (S.size() * 4 + 7 >= 4 * N)
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~
combo.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             if (l == S.size() + 2)
      |                 ~~^~~~~~~~~~~~~~~
combo.cpp:34:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             else if (l == S.size() + 1)
      |                      ~~^~~~~~~~~~~~~~~
combo.cpp:41:19: 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 (l == S.size() + 2)
      |                 ~~^~~~~~~~~~~~~~~
combo.cpp:43:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             else if (l == S.size() + 1)
      |                      ~~^~~~~~~~~~~~~~~
combo.cpp:50:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |             if (l == S.size() + 2)
      |                 ~~^~~~~~~~~~~~~~~
combo.cpp:52:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             else if (l == S.size() + 1)
      |                      ~~^~~~~~~~~~~~~~~
combo.cpp:59:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |             if (l == S.size() + 2)
      |                 ~~^~~~~~~~~~~~~~~
combo.cpp:61:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             else if (l == S.size() + 1)
      |                      ~~^~~~~~~~~~~~~~~
combo.cpp:68:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   68 |     while (S.size() < N)
      |            ~~~~~~~~~^~~
combo.cpp:70:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |         if (press(S + "A" + S + "B") == S.size() + 1)
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:72:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |             if (press(S + "A") == S.size() + 1)
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:79:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |             if (press(S + "X") == S.size() + 1)
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...