Submission #136516

#TimeUsernameProblemLanguageResultExecution timeMemory
136516shenxyCombo (IOI18_combo)C++11
100 / 100
51 ms552 KiB
#include "combo.h" #include <string> #include <algorithm> using namespace std; string guess_sequence(int N) { string p = "", k = ""; if (press("AB") != 0) { if (press("A") != 0) { p = "A"; k = "BXY"; } else { p = "B"; k = "AXY"; } } else { if (press("X") != 0) { p = "X"; k = "ABY"; } else { p = "Y"; k = "ABX"; } } while (p.length() < N - 1) { int x = press(p + k[0] + k[1] + p + k[0] + k[2] + p + k[0] + k[0] + p + k[1]); if (x == p.length() + 2) p += k[0]; else if (x == p.length() + 1) p += k[1]; else p += k[2]; } if (p.length() == N) return p; if (press(p + k[0]) == N) return p + k[0]; else if (press(p + k[1]) == N) return p + k[1]; else return p + k[2]; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   while (p.length() < N - 1) {
      |          ~~~~~~~~~~~^~~~~~~
combo.cpp:26:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     if (x == p.length() + 2) p += k[0];
      |         ~~^~~~~~~~~~~~~~~~~
combo.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     else if (x == p.length() + 1) p += k[1];
      |              ~~^~~~~~~~~~~~~~~~~
combo.cpp:30:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |   if (p.length() == N) return p;
      |       ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...