Submission #104392

#TimeUsernameProblemLanguageResultExecution timeMemory
104392dupreezCombo (IOI18_combo)C++14
100 / 100
53 ms588 KiB
#include "combo.h" #include <iostream> using namespace std; string guess_sequence(int N) { string cs = ""; int fl[4] = {}; string l[3],l2[4] = { "A","B","X","Y" }; if (press("AB")>0) { if (press("A") == 1) { cs = "A"; fl[0] = 1; } else { cs = "B"; fl[1] = 1; } } else { if (press("X")==1) { cs = "X"; fl[2] = 1; } else { cs = "Y"; fl[3] = 1; } } for (int i = 0, i2 = 0; i < 4; i++) { if (fl[i] == 1)continue; l[i2] = l2[i]; i2++; } while (cs.length() < N-1) { string cs2 = cs + l[1]; for (int i = 0; i < 3; i++)cs2 += cs + l[2] + l[i]; cs+=l[press(cs2)-cs.size()]; } if (cs.length() < N) { if (press(cs + "A" + cs + "B") > cs.length()) { if (press(cs + "A") > cs.length())return cs + "A"; return cs + "B"; } else { if (press(cs + "X") > cs.length())return cs + "X"; return cs + "Y"; } } else return cs; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |  while (cs.length() < N-1) {
      |         ~~~~~~~~~~~~^~~~~
combo.cpp:27:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |  if (cs.length() < N) {
      |      ~~~~~~~~~~~~^~~
combo.cpp:28:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if (press(cs + "A" + cs + "B") > cs.length()) {
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:29:24: 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 (press(cs + "A") > cs.length())return cs + "A";
      |        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    if (press(cs + "X") > cs.length())return cs + "X";
      |        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...