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 <iostream>
using namespace std;
int press(string p);
string guess_sequence(int n)
{
int nb;
string combo = "", entree = "";
char debut;
nb = press("AB");
if(nb >= 1)
{
nb = press("A");
if(nb == 1)
combo = "A";
else
combo = "B";
}
else
{
nb = press("X");
if(nb == 1)
combo = "X";
else
combo = "Y";
}
debut = combo[0];
for(int loop = 1; loop < n-1; ++loop)
{
entree = "";
if(debut == 'A')
{
entree += combo;
entree += "BB";
entree += combo;
entree += "BX";
entree += combo;
entree += "BY";
entree += combo;
entree += "X";
nb = press(entree);
if(nb - combo.size() == 0)
combo += 'Y';
else if(nb - combo.size() == 1)
combo += 'X';
else
combo += 'B';
}
else if(debut == 'B')
{
entree += combo;
entree += "AA";
entree += combo;
entree += "AX";
entree += combo;
entree += "AY";
entree += combo;
entree += "X";
nb = press(entree);
if(nb - combo.size() == 0)
combo += 'Y';
else if(nb - combo.size() == 1)
combo += 'X';
else
combo += 'A';
}
else if(debut == 'X')
{
entree += combo;
entree += "AA";
entree += combo;
entree += "AB";
entree += combo;
entree += "AY";
entree += combo;
entree += "B";
nb = press(entree);
if(nb - combo.size() == 0)
combo += 'Y';
else if(nb - combo.size() == 1)
combo += 'B';
else
combo += 'A';
}
else if(debut == 'Y')
{
entree += combo;
entree += "BA";
entree += combo;
entree += "BB";
entree += combo;
entree += "BX";
entree += combo;
entree += "A";
nb = press(entree);
if(nb - combo.size() == 0)
combo += 'X';
else if(nb - combo.size() == 1)
combo += 'A';
else
combo += 'B';
}
}
entree = "";
entree = combo;
entree += 'A';
entree += combo;
entree += 'B';
nb = press(entree);
if(n > 1)
{
if(nb == n)
{
entree = "";
entree = combo;
entree += 'A';
nb = press(entree);
if(nb == n)
combo += 'A';
else
combo += 'B';
}
else
{
entree = "";
entree = combo;
entree += 'X';
nb = press(entree);
if(nb == n)
combo += 'X';
else
combo += 'Y';
}
}
return combo;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |