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 "combo.h"
using namespace std;
string guess_sequence(int N) {
string p = "";
p="AB";
int coins = press(p);
if (coins!=0) {
p="A";
coins = press(p);
if (coins==0) p="B";
} else {
p="X";
coins = press(p);
if (coins==0) p="Y";
}
string S = p;
if (p=="A"){
while ((int) S.size() != N-1){
p=S;
p+='B';
p+=S;
p+="XX";
p+=S;
p+="XB";
p+=S;
p+="XY";
coins = press(p);
if (coins == (int) S.size()) S+='Y';
else if (coins == (int) S.size()+1) S+='B';
else S+='X';
}
p=S;
p+='B';
coins = press(p);
if (coins == N) S+='B';
else {
p=S;
p+='X';
coins = press(p);
if (coins == N) S+='X';
else S+='Y';
}
} else if (p=="B"){
while ((int) S.size() != N-1){
p=S;
p+='A';
p+=S;
p+="XX";
p+=S;
p+="XA";
p+=S;
p+="XY";
coins = press(p);
if (coins == (int) S.size()) S+='Y';
else if (coins == (int) S.size()+1) S+='A';
else S+='X';
}
p=S;
p+='A';
coins = press(p);
if (coins == N) S+='A';
else {
p=S;
p+='X';
coins = press(p);
if (coins == N) S+='X';
else S+='Y';
}
} else if (p=="X"){
while ((int) S.size() != N-1){
p=S;
p+='B';
p+=S;
p+="AA";
p+=S;
p+="AB";
p+=S;
p+="AY";
coins = press(p);
if (coins == (int) S.size()) S+='Y';
else if (coins == (int) S.size()+1) S+='B';
else S+='A';
}
p=S;
p+='B';
coins = press(p);
if (coins == N) S+='B';
else {
p=S;
p+='A';
coins = press(p);
if (coins == N) S+='A';
else S+='Y';
}
} else {
while ((int) S.size() != N-1){
p=S;
p+='B';
p+=S;
p+="XX";
p+=S;
p+="XB";
p+=S;
p+="XA";
coins = press(p);
if (coins == (int) S.size()) S+='A';
else if (coins == (int) S.size()+1) S+='B';
else S+='X';
}
p=S;
p+='B';
coins = press(p);
if (coins == N) S+='B';
else {
p=S;
p+='X';
coins = press(p);
if (coins == N) S+='X';
else S+='A';
}
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |