Submission #395107

#TimeUsernameProblemLanguageResultExecution timeMemory
395107jeroenodbCombo (IOI18_combo)C++14
100 / 100
55 ms680 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pi; const int mxN = 1e5+1, oo = 1e9; std::string guess_sequence(int N) { int n = N; string but = "ABXY"; if(press("AB")) { swap(but[press("B")], but[0]); } else { swap(but[press("Y")+2], but[0]); } string pref; pref+=but[0]; if(n==1) return pref; for(int i=1;i<n-1;++i) { string query = pref+but[1]; for(int j=1;j<4;++j) { query+=pref+but[2]+but[j]; } int coins = press(query); if(coins == pref.size()) { pref+=but[3]; } else if(coins == pref.size()+1) { pref+=but[1]; } else { pref+=but[2]; } } // check last character random_shuffle(but.begin()+1, but.end()); if(press(pref+but[1]+pref+but[2])==n) { if(press(pref+but[1])==n) { pref+=but[1]; } else pref+=but[2]; } else pref+=but[3]; return pref; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if(coins == pref.size()) {
      |            ~~~~~~^~~~~~~~~~~~~~
combo.cpp:32:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         } else if(coins == pref.size()+1) {
      |                   ~~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...