Submission #710985

#TimeUsernameProblemLanguageResultExecution timeMemory
710985abc864197532Combo (IOI18_combo)C++17
100 / 100
34 ms628 KiB
#include "combo.h" using namespace std; string s = "ABXY"; string guess_sequence(int N) { string ans; if (press("AB") > 0) { if (press("A") > 0) { ans += "A"; } else { ans += "B"; } } else { if (press("X") > 0) { ans += "X"; } else { ans += "Y"; } } string t; for (char c : s) if (ans[0] != c) { t += c; } while (ans.size() + 1 < N) { int res = press(ans + t[0] + t[0] + ans + t[0] + t[1] + ans + t[0] + t[2] + ans + t[1]); if (res == ans.size()) { ans += t[2]; } else if (res == ans.size() + 1) { ans += t[1]; } else { ans += t[0]; } } if (ans.size() != N) { if (press(ans + t[0]) > ans.size()) { ans += t[0]; } else if (press(ans + t[1]) > ans.size()) { ans += t[1]; } else { ans += t[2]; } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |   while (ans.size() + 1 < N) {
      |          ~~~~~~~~~~~~~~~^~~
combo.cpp:27:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     if (res == ans.size()) {
      |         ~~~~^~~~~~~~~~~~~
combo.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     } else if (res == ans.size() + 1) {
      |                ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:35:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |   if (ans.size() != N) {
      |       ~~~~~~~~~~~^~~~
combo.cpp:36:27: 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 (press(ans + t[0]) > ans.size()) {
      |         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:38:34: 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 (press(ans + t[1]) > ans.size()) {
      |                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...