Submission #1015446

#TimeUsernameProblemLanguageResultExecution timeMemory
1015446TroySerCombo (IOI18_combo)C++17
100 / 100
21 ms1896 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string LETTERS = "ABXY"; char firsty; if (press("AB") >= 1) { if (press("A") == 1) firsty = 'A'; else firsty = 'B'; } else { if (press("X") == 1) firsty = 'X'; else firsty = 'Y'; } string currString = ""; currString += firsty; if (N == 1) { return currString; } char ind[3]; int indy = 0; for (int i = 0; i < LETTERS.size(); i++) { if (LETTERS[i] != firsty) { ind[indy] = LETTERS[i]; indy++; } } for (int i = 1; i < N-1; i++) { int res = press(currString + ind[0] + currString + ind[1] + ind[0] + currString + ind[1] + ind[1] + currString + ind[1] + ind[2]); if (res == currString.size()) { currString += ind[2]; } else if (res == currString.size() + 1) { currString += ind[0]; } else { currString += ind[1]; } } if (press(currString + "A" + currString + "B") == N) { if (press(currString + "A") == N) currString += "A"; else currString += "B"; } else { if (press(currString + "X") == N) currString += "X"; else currString += "Y"; } return currString; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for (int i = 0; i < LETTERS.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~~
combo.cpp:36:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   if (res == currString.size()) {
      |       ~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   } else if (res == currString.size() + 1) {
      |              ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...