Submission #766872

#TimeUsernameProblemLanguageResultExecution timeMemory
766872jakobrsCombo (IOI18_combo)C++17
0 / 100
0 ms208 KiB
#include <iostream> #include <random> 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")) { if (press("A")) { std::swap(cha, cha); } else { std::swap(cha, chb); } } else { if (press("X")) { 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 += chb; } else if (press(guess + chx)) { 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; } } } return guess; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:62: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]
   62 |             if (result == guess.size()) {
      |                 ~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:64: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]
   64 |             } else if (result == guess.size() + 1) {
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...