Submission #317845

#TimeUsernameProblemLanguageResultExecution timeMemory
317845Drew_Combo (IOI18_combo)C++14
100 / 100
46 ms584 KiB
#include "combo.h" std::string guess_sequence(int n) { std::string s = ""; int coins; char rem[10]; coins = press("AB"); if (coins == 0) { rem[0] = 'A'; rem[1] = 'B'; coins = press("X"); if (coins == 1) s += 'X', rem[2] = 'Y'; else s += 'Y', rem[2] = 'X'; } else { rem[1] = 'X'; rem[2] = 'Y'; coins = press("A"); if (coins == 1) s += 'A', rem[0] = 'B'; else s += 'B', rem[0] = 'A'; } while (s.size() < n-1) { std::string p = ""; for (int i = 0; i < 3; ++i) p += (s + rem[0] + rem[i]); p += s + rem[1]; coins = press(p); if (coins >= s.size()+2) s += rem[0]; else if (coins == s.size()+1) s += rem[1]; else s += rem[2]; } if (s.size() < n) { if (press(s + rem[0]) == n) s += rem[0]; else if (press(s + rem[1]) == n) s += rem[1]; else s += rem[2]; } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     while (s.size() < n-1)
      |            ~~~~~~~~~^~~~~
combo.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if (coins >= s.size()+2) s += rem[0];
      |             ~~~~~~^~~~~~~~~~~~~
combo.cpp:38:24: 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 (coins == s.size()+1) s += rem[1];
      |                  ~~~~~~^~~~~~~~~~~~~
combo.cpp:42:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |     if (s.size() < n)
      |         ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...