Submission #107267

#TimeUsernameProblemLanguageResultExecution timeMemory
107267kyunamkCombo (IOI18_combo)C++14
30 / 100
116 ms704 KiB
#include "combo.h" #include <vector> #include <iostream> using namespace std; static int debug = false; string guess_sequence(int N) { // /debug = true; string p = ""; vector<char> b ; b.push_back('A'); b.push_back('B'); b.push_back('X'); b.push_back('Y'); string prefix =""; if ( press("AB") ) { //AB if (press("A") ) { prefix = "A"; b.erase(b.begin()+0); } else { prefix = "B"; b.erase(b.begin()+1); } } else { //AB if (press("X") ) { prefix = "X"; b.erase(b.begin()+2); } else { prefix = "Y"; b.erase(b.begin()+3); } } if(debug) cout << b[0] << b[1] << b[2] << endl; while ( prefix.length() < N ) { int i = 0 ; int n = 0; string append = prefix; int skip = -1; for( i = 0 ; i < 2 ; i++ ) { if (skip==i) { skip = -1; continue; } append = prefix; string s =""; while( s.length() + append.length()+1 <= N*4 ) { append.append(1,b[i]); s+=append; } if(debug) cout << s << " "; n = press(s) ; if(debug) cout << n << endl; if ( n > prefix.length()) { break; } } if ( n > prefix.length()) { skip = i; for( i = prefix.length() ; i < n ; i++ ){ prefix.append(1,append[i]); } if(debug) cout << "prefix " << prefix << endl; } else { prefix.append(1,b[i]); if(debug) cout << "prefix " << prefix << endl; } } if(debug) cout << prefix << endl; return prefix; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:47:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |   while ( prefix.length() < N ) {
      |           ~~~~~~~~~~~~~~~~^~~
combo.cpp:60:45: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |       while( s.length() + append.length()+1 <= N*4 ) {
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
combo.cpp:67:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |       if ( n > prefix.length()) {
      |            ~~^~~~~~~~~~~~~~~~~
combo.cpp:71:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     if ( n > prefix.length()) {
      |          ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...