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"
// #include <iostream>
using namespace std;
string guess_sequence(int N) {
int l=1,k;
string s;
if (press("A")){
s="A";
while (l<N){
if (l==N-1){
k=press(s+"B");
if (k>l) s+="B";
else if ((k=press(s+"X"))>l) s+="X";
else s+="Y";
break;
}
k=press(s+"B"+s+"XB"+s+"XX"+s+"XY");
if (k==l) {
s+="Y";
l++;
}
if (k==l+1){
s+="B";
l++;
}
if (k==l+2){
s+="X";
l++;
}
}
}
else if (press("B")){
s="B";
while (l<N){
if (l==N-1){
k=press(s+"A");
if (k>l) s+="A";
else if ((k=press(s+"X"))>l) s+="X";
else s+="Y";
break;
}
k=press(s+"A"+s+"XA"+s+"XX"+"XY");
if (k==l) {
s+="Y";
l++;
}
if (k==l+1){
s+="A";
l++;
}
if (k==l+2){
s+="X";
l++;
}
}
}
else if (press("X")){
s="X";
while (l<N){
if (l==N-1){
k=press(s+"B");
if (k>l) s+="B";
else if ((k=press(s+"A"))>l) s+="A";
else s+="Y";
break;
}
k=press(s+"B"+s+"AB"+s+"AA"+"AY");
if (k==l) {
s+="Y";
l++;
}
if (k==l+1){
s+="B";
l++;
}
if (k==l+2){
s+="A";
l++;
}
}
}
else {
s="Y";
while (l<N){
if (l==N-1){
k=press(s+"B");
if (k>l) s+="B";
else if ((k=press(s+"X"))>l) s+="X";
else s+="A";
break;
}
k=press(s+"B"+s+"XB"+s+"XX"+"XA");
if (k==l) {
s+="A";
l++;
}
if (k==l+1){
s+="B";
l++;
}
if (k==l+2){
s+="X";
l++;
}
}
}
// cerr << s << " \n";
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |