Submission #151509

#TimeUsernameProblemLanguageResultExecution timeMemory
151509Linca_RobertCombo (IOI18_combo)C++14
5 / 100
3 ms296 KiB
#include<bits/stdc++.h> #include "combo.h" std::string guess_sequence( int N ) { std::string p = ""; std::string S = ""; char c[] = {'A', 'B', 'X', 'Y'}; p.push_back( 'A' ); p.push_back( 'B' ); if( press(p) != 0 ){ p.clear(); p.push_back( 'A' ); if( press(p) == 1 ) S.push_back( 'A' ); else S.push_back( 'B' ), std::swap( c[0], c[1] ); }else{ p.clear(); p.push_back( 'X' ); if( press(p) == 1 ) S.push_back( 'X' ), std::swap( c[0], c[2] ); else S.push_back( 'Y' ), std::swap( c[0], c[3] ); } for( int i = 2; i < N; i++ ){ p.clear(); p.append( S ); p.push_back( c[1] ); p.append( S ); p.push_back( c[2] ); p.push_back( c[1] ); p.append( S ); p.push_back( c[2] ); p.push_back( c[2] ); p.append( S ); p.push_back( c[2] ); p.push_back( c[3] ); ///std::cout << p << "\n"; int ans = press( p ); if( ans == i ) S.push_back( c[1] ); else if( ans == i + 1 ) S.push_back( c[2] ); else S.push_back( c[3] ); } p.clear(); p = S; p.push_back( c[1] ); if( press(p) == N ){ S = p; }else{ p.back() = c[2]; if( press(p) == N ) S = p; else S.push_back( c[3] ); } return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...