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"
std::string guess_sequence( int N ) {
std::string p = "";
std::string S = "";
char c[] = {'A', 'B', 'X', 'Y'};
p.push_back( 'A' );
p.push_back( 'B' );
if( press(p) != 0 ){
p.clear(); p.push_back( 'A' );
if( press(p) == 1 )
S.push_back( 'A' );
else
S.push_back( 'B' ), std::swap( c[0], c[1] );
}else{
p.clear(); p.push_back( 'X' );
if( press(p) == 1 )
S.push_back( 'X' ), std::swap( c[0], c[2] );
else
S.push_back( 'Y' ), std::swap( c[0], c[3] );
}
for( int i = 2; i < N; i++ ){
p.clear();
p.append( S ); p.push_back( c[1] );
p.push_back( c[0] );
p.append( S ); p.push_back( c[2] ); p.push_back( c[1] );
p.push_back( c[0] );
p.append( S ); p.push_back( c[2] ); p.push_back( c[3] );
p.push_back( c[0] );
int ans = press( p );
if( ans == i )
S.push_back( c[1] );
else
if( ans == i + 1 )
S.push_back( c[2] );
else
S.push_back( c[3] );
}
p.clear();
p = S;
p.push_back( c[1] );
if( press(p) == N ){
S = p;
}else{
p.back() = c[2];
if( press(p) == N )
S = p;
else
S.push_back( c[3] );
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |