제출 #196922

#제출 시각아이디문제언어결과실행 시간메모리
196922Dilshod_Imomov콤보 (IOI18_combo)C++17
100 / 100
89 ms624 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; char start( string &s ) { char c; if ( press("AB") ) { if ( press("A") ) c = 'A'; else c = 'B'; } else { if ( press("X") ) c = 'X'; else c = 'Y'; } for ( auto i: "ABXY" ) { if ( i != c ) s += i; } return c; } char end( string S, string s, int N ) { if ( press( S + s[0] + S + s[1] ) == N ) { if ( press( S + s[0] ) == N ) return s[0]; else return s[1]; } return s[2]; } string generate( string S, string s ) { return S + s[0] + S + s[1] + s[0] + S + s[1] + s[1] + S + s[1] + s[2]; } string guess_sequence(int N) { string S, s, p; S += start(s); for ( int i = 1; i < N - 1; i++ ) { p = generate( S, s ); int x = press(p); if ( x == i + 1 ) S += s[0]; else if ( x == i ) S += s[2]; else S += s[1]; } if ( N != 1 ) S += end(S, s, N); return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...