Submission #826968

#TimeUsernameProblemLanguageResultExecution timeMemory
826968wortelwormCombo (IOI18_combo)C++17
100 / 100
27 ms564 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { char first; int coins = press("AB"); if (coins > 0) { coins = press("A"); if (coins > 0) { first = 'A'; } else { first = 'B'; } } else { coins = press("X"); if (coins > 0) { first = 'X'; } else { first = 'Y'; } } string result = ""; result += first; string options; for (char c : "ABXY") { if (c != first) { options += c; } } for (int i = 1; i < N; i++) { if (4*i + 7 <= 4*N) { coins = press(result + options[0] + result + options[1] + options[0] + result + options[1] + options[1] + result + options[1] + options[2]); if (coins == result.size() + 1) { result += options[0]; } else if (coins == result.size() + 2) { result += options[1]; } else { result += options[2]; } } else { for (int j = 0; j < 2; j++) { coins = press(result + options[j]); if (coins > result.size()) { // this is correct result += options[j]; } } if (result.size() == i) { result += options[2]; } } } return result; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:43:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             if (coins == result.size() + 1) {
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:45:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             } else if (coins == result.size() + 2) {
      |                        ~~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:53:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |                 if (coins > result.size()) {
      |                     ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:58:31: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |             if (result.size() == i) {
      |                 ~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...