Submission #402743

#TimeUsernameProblemLanguageResultExecution timeMemory
402743luisgalanCombo (IOI18_combo)C++14
5 / 100
2 ms256 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; #define debug(x) cerr << #x << " = " << (x) << endl char chars[4] = {'A', 'B', 'X', 'Y'}; string guess_sequence(int N) { string res = ""; char init; if (press("AB")) { init = press("A") ? 'A' : 'B'; } else { init = press("X") ? 'X' : 'Y'; } res += init; vector<char> others; vector<string> others_s; for (int i = 0; i < 4; i++) { if (chars[i] == init) continue; others.push_back(chars[i]); others_s.push_back(string(1, chars[i])); } while (res.size() + 1 < N) { string query = ""; query += res + others_s[0] + others_s[0]; query += res + others_s[0] + others_s[1]; query += res + others_s[0] + others_s[2]; query += res + others_s[1]; // debug(query); int delta_coins = press(query) - res.size(); // debug(delta_coins); if (delta_coins == 2) { res += others_s[0]; } else if (delta_coins == 1) { res += others_s[1]; } else { res += others_s[2]; } // debug(res); } if (press(res + others_s[0] + res + others_s[1]) > res.size()) { if (press(res + others_s[0]) > res.size()) { res += others_s[0]; } else { res += others_s[1]; } } else { res += others_s[2]; } // debug(res); return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     while (res.size() + 1 < N) {
      |            ~~~~~~~~~~~~~~~^~~
combo.cpp:44:54: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     if (press(res + others_s[0] + res + others_s[1]) > res.size()) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:45:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if (press(res + others_s[0]) > res.size()) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...