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;
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define pb push_back
string guess_sequence (int n){
string buttons ,s;
if( press("A")==1 ) s.pb('A') , buttons = "BXY" ;
else if( press("B")==1 ) s.pb('B') , buttons = "AXY" ;
else if( press("X")==1 ) s.pb('X') , buttons = "ABY" ;
else s.pb('Y' ) , buttons = "ABX" ;
for(int i = 1 ; i < n ; i++ ){
if( i == 1 ) {
for( char b : buttons ){
int ans = press ( s + b + buttons[0] ) ;
if( ans == i+1 ){
s+=b ; break ;
}
if( ans == i+2 ) {
s+= b ;
s+= buttons[0] ;
i ++ ;
break ;
}
}
continue ;
}
string s2 = s ;
s2 += buttons [1] ;
for(int j=s2.length() ; j < n*4 ; j++ ) s2.pb(buttons[0]) ;
int ans = press ( s2 ) ;
if( ans > i ){
s.pb(buttons[1]) ; ans -- ;
for(; i < ans && (int)s.length() < n ; i++ )s.pb(buttons[0]) ;
}
else s += buttons[2] ;
}
assert( (int)s.length() == n) ;
return s ;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |