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>
using namespace std; using ll=long long;
int press(std::string p);
string guess_sequence(int N){
string S = "", first, a1, a2, a3;
if(press("AB")) {
if(press("A")) first="A", S="A", a1="B", a2="X", a3="Y";
else first="B", S="B", a1="A", a2="X", a3="Y";
} else {
if(press("X")) first="X", S="X", a1="B", a2="A", a3="Y";
else first="Y", S="Y", a1="B", a2="X", a3="A";
}
vector<string> a{a1, a2, a3};
while(true){
int curr_size = S.size();
if(curr_size == N)
return S;
if(curr_size<N-2){
ll nxt = press(S+a1+a1 + S+a1+a2 + S+a1+a3 + S+a2) - curr_size;
if(nxt==2) S+=a1;
if(nxt==1) S+=a2;
if(nxt==0) S+=a3;
} else {
if(press(S+a1+S+a2)){
if(press(S+a1)) S+=a1;
else S+=a2;
} else
S+=a3;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |