이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |