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;
string guess_sequence(int N) {
string resp;
vector<char> opcoes;
if( press("AB") ){
if( press("A") ) resp.push_back('A'), opcoes = { 'B', 'X', 'Y' };
else resp.push_back('B'), opcoes = { 'A', 'X', 'Y' };
}
else{
if( press("X") ) resp.push_back('X'), opcoes = { 'B', 'A', 'Y' };
else resp.push_back('Y'), opcoes = { 'B', 'X', 'A' };
}
for( int i = 1; i < N - 1; i++ ){
string s;
for( char c : opcoes ) s = s + resp + opcoes[0] + c;
s = s + resp + opcoes[1];
int aux = press(s);
if( aux == i ) resp.push_back(opcoes[2]);
else if( aux == i + 1 ) resp.push_back(opcoes[1]);
else resp.push_back(opcoes[0]);
}
string s = resp + opcoes[0];
if( press(resp + opcoes[0]) == N ) return resp + opcoes[0];
if( press(resp + opcoes[1]) == N ) return resp + opcoes[1];
return resp + opcoes[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |