Submission #106809

#TimeUsernameProblemLanguageResultExecution timeMemory
106809LamoreauxAJCombo (IOI18_combo)C++14
100 / 100
40 ms624 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] + S + rem[1] + rem[1]; int coins = press(P); if (coins == S.size()) S += rem[2]; else if (coins == S.size() + 1) S += rem[0]; else S += rem[1]; // cout << "guessed: " << P << "\n"; // cout << S << "\n"; } 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:39:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |       if (press(S + rem[0]) > S.size())
      |           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp:41:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |       else if (press(S + rem[1]) > S.size())
      |                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...