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>
#include <combo.h>
using namespace std;
#define pb push_back
char guess_first(){
int ans = press("AB");
if(ans==0){
ans=press("X");
if(ans==1){
return 'X';
}
return 'Y';
}
else{
ans=press("A");
if(ans==1){
return 'A';
}
return 'B';
}
}
string guess_sequence(int n){
char f = guess_first();
vector<char> nf;
if('A'!=f)nf.pb('A');
if('B'!=f)nf.pb('B');
if('X'!=f)nf.pb('X');
if('Y'!=f)nf.pb('Y');
int gsd=1;
string ans= "";
ans+=f;
if(n==1){
return ans;
}
while(gsd<n-1){
string gs=ans+nf[0]+nf[0]+ans+nf[0]+nf[1]+ans+nf[0]+nf[2]+ans+nf[1];
int kita=press(gs);
if(kita==gsd){
ans+=nf[2];
}
else if(kita==gsd+1){
ans+=nf[1];
}
else if(kita==gsd+2){
ans+=nf[0];
}
gsd++;
}
string gs=ans+nf[0];
if(press(gs)==n){
return gs;
}
else{
gs.pop_back();
gs+=nf[1];
if(press(gs)==n){
return gs;
}
else{
gs.pop_back();
return gs+nf[2];
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |