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 = "";
string guess_sequence (int nbCaracteres)
{
if (press("AB") > 0) {
res += press("A") ? 'A' : 'B';
}
else {
res += press("X") ? 'X' : 'Y';
}
if (nbCaracteres == 1) {
return res;
}
string caracteres;
for (char c : "ABXY") {
if (c != res[0] && c != 0) {
caracteres.push_back(c);
}
}
while ((int)res.size() < nbCaracteres-1) {
const int reponse = press(res+caracteres[0]
+ res+caracteres[1]+caracteres[0] + res+caracteres[1]+caracteres[1] + res+caracteres[1]+caracteres[2]);
if (reponse == (int)res.size()+2) {
res += caracteres[1];
}
else if (reponse == (int)res.size()+1) {
res += caracteres[0];
}
else {
res += caracteres[2];
}
}
if (press(res+caracteres[0]) == nbCaracteres) {
return res + caracteres[0];
}
if (press(res+caracteres[1]) == nbCaracteres) {
return res + caracteres[1];
}
return res + caracteres[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |