제출 #196919

#제출 시각아이디문제언어결과실행 시간메모리
196919Dilshod_Imomov콤보 (IOI18_combo)C++17
97 / 100
61 ms632 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; char start( string &s ) { char c; if ( press("A") ) c = 'A'; else if ( press("B") ) 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]) == N ) return s[0]; else if ( press(S + s[1]) == N ) 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...