Submission #96609

#TimeUsernameProblemLanguageResultExecution timeMemory
96609diamond_dukeCombo (IOI18_combo)C++11
100 / 100
178 ms572 KiB
#include "combo.h" #include <algorithm> std::string guess_sequence(int n) { std::string str = press("AB") ? (press("A") ? "A" : "B") : (press("X") ? "X" : "Y"); if (n == 1) return str; std::string alpha = "ABXY"; for (int i = 0; i < 4; i++) { if (alpha[i] == str[0]) std::swap(alpha[i], alpha[3]); } for (int i = 1; i + 1 < n; i++) { auto qry = str + alpha[1] + str + alpha[2] + alpha[0] + str + alpha[2] + alpha[1] + str + alpha[2] + alpha[2]; int res = press(qry); if (res == str.size()) str += alpha[0]; else if (res == str.size() + 1) str += alpha[1]; else str += alpha[2]; } if (press(str + alpha[0]) == str.size() + 1) str += alpha[0]; else if (press(str + alpha[1]) == str.size() + 1) str += alpha[1]; else str += alpha[2]; return str; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:23:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   if (res == str.size())
      |       ~~~~^~~~~~~~~~~~~
combo.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   else if (res == str.size() + 1)
      |            ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:30:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  if (press(str + alpha[0]) == str.size() + 1)
      |      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:32:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  else if (press(str + alpha[1]) == str.size() + 1)
      |           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...