Submission #766880

#TimeUsernameProblemLanguageResultExecution timeMemory
766880jakobrsCombo (IOI18_combo)C++17
100 / 100
27 ms500 KiB
#include <iostream> #include <random> #include <string> std::string guess_sequence(int N); int press(std::string p); using i64 = int64_t; std::string guess_sequence(int n) { std::mt19937 rng(102435324); char cha = 'A'; char chb = 'B'; char chx = 'X'; char chy = 'Y'; if (press("AB") > 0) { if (press("A") > 0) { std::swap(cha, cha); } else { std::swap(cha, chb); } } else { if (press("X") > 0) { std::swap(cha, chx); } else { std::swap(cha, chy); } } std::string guess = { cha }; std::string seq; for (i64 i = 1; i < n; i++) { if (i == n - 1) { if (press(guess + chb) > guess.size()) { guess += chb; } else if (press(guess + chx) > guess.size()) { guess += chx; } else { guess += chy; } } else { seq.clear(); seq.append(guess); seq.push_back(chb); seq.append(guess); seq.push_back(chx); seq.push_back(chb); seq.append(guess); seq.push_back(chx); seq.push_back(chx); seq.append(guess); seq.push_back(chx); seq.push_back(chy); i64 result = press(seq); if (result == guess.size()) { guess += chy; } else if (result == guess.size() + 1) { guess += chb; } else { guess += chx; } } } // std::cout << guess << '\n'; return guess; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             if (press(guess + chb) > guess.size()) {
      |                 ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:40:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             } else if (press(guess + chx) > guess.size()) {
      |                        ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:65:24: warning: comparison of integer expressions of different signedness: 'i64' {aka 'long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |             if (result == guess.size()) {
      |                 ~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:67:31: warning: comparison of integer expressions of different signedness: 'i64' {aka 'long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             } else if (result == guess.size() + 1) {
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...