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>
using namespace std ;
#include "combo.h"
int n ;
string ans , but = "ABXY" , ret ;
int query ( string s ) {
return press (s) ;
}
void solve () {
string crnt = "" ;
for ( int i = 0 ; i < 3 ; i ++ ) {
crnt += ans ;
crnt += ret [0] ;
crnt += ret [i] ;
}
crnt += ans ;
crnt += ret [1] ;
int x = query ( crnt ) ;
x -= ans .size () ;
if ( x == 0 ) {
ans += ret [2] ;
}
if ( x == 1 ) {
ans += ret [1] ;
}
if ( x == 2 ) {
ans += ret [0] ;
}
}
string guess_sequence ( int N ) {
n = N ;
if ( query ( "AB" ) ) {
if ( query ( "A" ) ) ans += 'A' ;
else ans += 'B' ;
}
else {
if ( query ( "X" ) ) ans += 'X' ;
else ans += 'Y' ;
}
for ( int i = 0 ; i < 4 ; i ++ ) {
if ( but [i] != ans [0] )
ret += but [i] ;
}
for ( int i = 1 ; i < n - 1 ; i ++ ) solve () ;
if ( n >= 2 ) {
string crnt = "" ;
crnt += ans ;
crnt += ret [0] ;
crnt += ans ;
crnt += ret [1] ;
if ( query ( crnt ) - ans .size () == 0 ) {
ans += ret [2] ;
}
else {
crnt = "" ;
crnt += ans ;
crnt += ret [0] ;
if ( query ( crnt ) - ans .size () == 0 ) {
ans += ret [1] ;
}
else ans += ret [0] ;
}
}
return ans ;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |