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<bits/stdc++.h>
using namespace std;
vector<string> LETTERS = {"A","B","X","Y"};
std::string guess_sequence(int N) {
string D="";
string guess = "AB";
int P=press(guess);
if(P==1){
guess="A";
P=press(guess);
if(P==1){
D="A";
}else{
D="B";
}
}else if(P==2){
D="A";
}else{
guess="X";
P=press(guess);
if(P==1){
D="X";
}else{
D="Y";
}
}
if(D=="")D=LETTERS[3];
vector<string> letters;
for(string&L:LETTERS){
if(L==D)continue;
letters.push_back(L);
}
string S=D;
for(int i=1;i<N-1;i++){
string guess = S+letters[0]+S+letters[1]+letters[0]+S+letters[1]+letters[1]+S+letters[1]+letters[2];
int P=press(guess);
if(P==(i+1)){
S+=letters[0];
}else if(P==(i+2)){
S+=letters[1];
}else{
S+=letters[2];
}
}
if(N!=1){
if(press(S+letters[0])==N){
S+=letters[0];
}else if(press(S+letters[1])==N){
S+=letters[1];
}else{
S+=letters[2];
}}
cerr<<S<<'\n';
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |