Submission #402735

#TimeUsernameProblemLanguageResultExecution timeMemory
402735luisgalanCombo (IOI18_combo)C++14
5 / 100
1 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; for (int i = 0; i < 4; i++) { if (chars[i] == init) continue; others.push_back(chars[i]); } while (res.size() + 1 < N) { string query = ""; query += res + others[0] + others[0]; query += res + others[0] + others[1]; query += res + others[0] + others[2]; query += res + others[1]; // debug(query); int delta_coins = press(query) - res.size(); // debug(delta_coins); if (delta_coins == 2) { res += others[0]; } else if (delta_coins == 1) { res += others[1]; } else { res += others[2]; } // debug(res); } if (press(res + others[0] + res + others[1]) > res.size()) { if (press(res + others[0]) > res.size()) { res += others[0]; } else { res += others[1]; } } else { res += others[2]; } // debug(res); return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     while (res.size() + 1 < N) {
      |            ~~~~~~~~~~~~~~~^~~
combo.cpp:42:50: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     if (press(res + others[0] + res + others[1]) > res.size()) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:43:36: 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 (press(res + others[0]) > res.size()) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...