# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
109663 | youssefbou62 | 콤보 (IOI18_combo) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.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
int press (string s ){cout<<"query "<<s<<endl;
int x ; cin>> x ; return x ;
}
string guess_sequence (int n){
string buttons ,s2,s;
int ans ;
if( n == 1 ){
if( press("A") ) return "A" ;
if( press("B") ) return "B" ;
if( press("X"))return "X" ;
return "Y" ;
}
ans = press("ABABXBY") ;
if( ans ){
if( ans == 1 ) s.pb('A') , buttons = "BXY";
if( ans == 2 ) s.pb('B') , buttons = "AXY" ;
}
else {
ans = press ( "XYAYBYX" ) ;
if( ans == 1 ) s.pb('X') , buttons = "ABY" ;
if( ans == 2 ) s.pb( 'Y' ) , buttons = "ABX" ;
}
while ( (int)s.length() != n ){
if( (int) s.length() == n-1 ) {
s2 = s + buttons[0] + s + buttons[1];
if( press ( s2 ) == (int)s.length() ){
s.pb(buttons[2]) ;
break ;
}
s2 = s + buttons[1] ;
if( press ( s2 ) == (int)s.length() + 1 ){
s.pb(buttons[1]) ;
break ;
}
s += buttons[0] ;
break ;
}
else
s2 = s + buttons[0] + s + buttons[1] + buttons[0] + s + buttons[1] + buttons[1] + s + buttons[1] + buttons[2] ;
ans = press ( s2 ) ;
if( ans == (int)s.length() ){
s.pb(buttons[2]) ;
}else if( ans == (int)s.length() + 1 ){
s.pb(buttons[0]) ;
}else if( ans == (int)s.length() + 2 ){
s.pb(buttons[1]);
}
}
assert( (int)s.length() == n) ;
return s ;
}
int main(){int n ; cin>> n ;
cout<<"answer is "<<guess_sequence(n)<<endl;
}