Submission #83804

#TimeUsernameProblemLanguageResultExecution timeMemory
83804AdrienVannsonCombo (IOI18_combo)C++17
30 / 100
66 ms484 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string res = ""; bool estSuivantAB; string guess_sequence (int nbElements) { if (press("AB") > 0) { res += press("A") ? 'A' : 'B'; } else { res += press("X") ? 'X' : 'Y'; } if (nbElements == 1) { return res; } if (res[0] == 'A' || res[0] == 'B') { estSuivantAB = press(res+"X"+res+"Y") <= (int)res.size(); } else { estSuivantAB = press(res+"A"+res+"B") > (int)res.size(); } while ((int)res.size() < nbElements) { bool doitRecalculer = false; char car1, car2; if (estSuivantAB) { car1 = 'A'; car2 = 'B'; } else { car1 = 'X'; car2 = 'Y'; } if (res[0] == car1) { res += car2; doitRecalculer = true; } else if (res[0] == car2) { res += car1; doitRecalculer = true; } else { string requete; if (res[0] != 'A') { requete += res+car1+'A'; } if (res[0] != 'B') { requete += res+car1+'B'; } const int reponse = press(requete); if (reponse > (int)res.size()) { estSuivantAB = reponse == (int)res.size() + 2; res += car1; } else { res += car2; doitRecalculer = true; } } if (doitRecalculer) { if (res[0] == 'A' || res[0] == 'B') { estSuivantAB = press(res+"X"+res+"Y") <= (int)res.size(); } else { estSuivantAB = press(res+"A"+res+"B") > (int)res.size(); } } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...