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>
int press(std::string p);
std::string guess_sequence(int n) {
std::string ans="";
if (press("AB")) {
if (press("A")) ans="A";
else ans="B";
} else {
if (press("X")) ans="X";
else ans="Y";
}
std::string f=ans;
int l=1;
while (l<n-1) {
if (f=="A") {
int a=press(ans+"B"+ans+"XB"+ans+"XX"+ans+"XY");
if (a==l) ans+="Y";
else if (a==l+1) ans+="B";
else ans+="X";
} else if (f=="B") {
int a=press(ans+"A"+ans+"XA"+ans+"XX"+ans+"XY");
if (a==l) ans+="Y";
else if (a==l+1) ans+="A";
else ans+="X";
} else if (f=="X") {
int a=press(ans+"B"+ans+"AB"+ans+"AA"+ans+"AY");
if (a==l) ans+="Y";
else if (a==l+1) ans+="B";
else ans+="A";
} else {
int a=press(ans+"B"+ans+"XB"+ans+"XX"+ans+"XA");
if (a==l) ans+="A";
else if (a==l+1) ans+="B";
else ans+="X";
}
l++;
}
if (n>1) {
if (press(ans+"A"+ans+"B")>l) {
if (press(ans+"A")>l) ans+="A";
else ans+="B";
} else {
if (press(ans+"X")>l) ans+="X";
else ans+="Y";
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |