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;
vector< char > guess{'A', 'B', 'X', 'Y'};
void recur(string &pref, int index){
if(index == 0) return;
string s = "";
s = pref + guess[0] + pref + guess[1] + guess[0] + pref + guess[1] + guess[1] + pref + guess[1] + guess[2];
int rep = press(s);
if(rep == (int)pref.size()){
pref += guess[2];
recur(pref, index - 1);
}else if(rep == (int)pref.size()+1){
pref = (pref + guess[0]);
recur(pref, index - 1);
}else{
pref = (pref + guess[1]);
recur(pref, index - 1);
}
}
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; i < 4; i++){
if(s[0] == guess[i]){
swap(guess[i], guess.back());
guess.pop_back();
break;
}
}
recur(s, N-2);
s += guess[0];
if(press(s) == N){
return s;
}
s.back() = guess[1];
if(press(s) == N) return s;
s.back() = guess[2];
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |