This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string res = "";
bool estSuivantAB;
string guess_sequence (int nbElements)
{
estSuivantAB = press("AB") > 0;
while ((int)res.size() < nbElements) {
const char interdit = res.size() ? res[0] : '_';
bool doitRecalculer = res.empty();
char car1, car2;
if (estSuivantAB) {
car1 = 'A';
car2 = 'B';
}
else {
car1 = 'X';
car2 = 'Y';
}
if (interdit == car1) {
res += car2;
doitRecalculer = true;
}
else if (interdit == car2) {
res += car1;
doitRecalculer = true;
}
else {
string requete;
if (interdit != 'A') {
requete += res+car1+'A';
}
else if (interdit != '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 (interdit == 'A' || interdit == 'B') {
estSuivantAB = press(res+"X"+res+"Y") <= (int)res.size();
}
else {
estSuivantAB = press(res+"A"+res+"B") > (int)res.size();
}
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |