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;
string C = "ABXY";
string guess_sequence(int n){
string s = "AB";
if(press(s)){
s = "A";
if(!press(s)) s = "B";
}
else{
s = "X";
if(!press(s)) s = "Y";
}
for(int i=0; C[i]; i++){
if(C[i]==s[0]){
C.erase(C.begin()+i);
break;
}
}
string S[4];
for(int i=0; i<4; i++) S[i] = s;
n--;
while(n){
int len = S[0].length();
if(n==1){
if(press(S[0]+"A"+S[0]+"B")>len){
if(press(S[0]+"A")>len) S[0].push_back('A');
else S[0].push_back('B');
}
else{
if(press(S[0]+"X")>len) S[0].push_back('X');
else S[0].push_back('Y');
}
}
else{
for(int i=0; i<3; i++) S[i].push_back(C[0]);
for(int i=0; i<3; i++) S[i].push_back(C[i]);
S[3].push_back(C[1]);
int ret = press(S[0]+S[1]+S[2]+S[3]);
for(int i=0; i<3; i++){
S[i].pop_back();
S[i].pop_back();
}
S[3].pop_back();
char ch;
if(ret==len) ch = C[2];
else if(ret==len+1) ch = C[1];
else ch = C[0];
for(int i=0; i<4; i++) S[i].push_back(ch);
}
n--;
}
return S[0];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |