Submission #106807

#TimeUsernameProblemLanguageResultExecution timeMemory
106807LamoreauxAJCombo (IOI18_combo)C++14
0 / 100
42 ms336 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"; } vector<char> rem = {'A', 'B', 'X', 'Y'}; for (int i = 0; i < rem.size(); i++) { if (rem[i] == S[0]) { rem.erase(rem.begin() + i); break; } } for (int i = 1; i < N - 1; i++) { string P = S + rem[0] + S + rem[1] + rem[0] + S + rem[1] + rem[2]; int coins = press(P); if (coins == S.size()) S += rem[2]; else if (coins == S.size() + 1) S += rem[0]; else S += rem[1]; } if (N > 1) { if (press(S + rem[0]) > S.size()) S += rem[0]; else if (press(S + rem[1]) > S.size()) S += rem[1]; else S += rem[2]; } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for (int i = 0; i < rem.size(); i++) {
      |                   ~~^~~~~~~~~~~~
combo.cpp:29:17: 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 (coins == S.size())
      |           ~~~~~~^~~~~~~~~~~
combo.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |       else if (coins == S.size() + 1)
      |                ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:37:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |       if (press(S + rem[0]) > S.size())
      |           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp:39:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |       else if (press(S + rem[1]) > S.size())
      |                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...