Submission #107288

#TimeUsernameProblemLanguageResultExecution timeMemory
107288kyunamkCombo (IOI18_combo)C++14
100 / 100
75 ms612 KiB
#include "combo.h" #include <iostream> using namespace std; static int debug = false; string guess_sequence(int N) { string p = ""; char *b; string prefix =""; if ( press("AB") ) { //AB if (press("A") ) { prefix = "A"; b="BXY"; } else { prefix = "B"; b="AXY"; } } else { //AB if (press("X") ) { prefix = "X"; b="ABY"; } else { prefix = "Y"; b="ABX"; } } if(debug) cout << b[0] << b[1] << b[2] << endl; int pn ; while ( (pn=prefix.length()) < N-1 ) { int i = 0 ; int n = 0; string s =""; s+=prefix; s+=b[1]; for ( i = 0 ; i < 3 ; i++) { s+=prefix; s+=b[2]; s+=b[i]; } if(debug) cout << s << " "; n = press(s) ; if(debug) cout << n << endl; prefix += b[n-pn]; if(debug) cout << "prefix " << prefix << endl; } if ( N > 1) { if ( press(prefix + b[0] + prefix + b[1]) == N ) { if ( press(prefix + b[0]) == N ) prefix+=b[0]; else prefix+=b[1]; } else { prefix+=b[2]; } } if(debug) cout << prefix << endl; return prefix; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:18:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   18 |       b="BXY";
      |         ^~~~~
combo.cpp:23:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   23 |       b="AXY";
      |         ^~~~~
combo.cpp:32:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   32 |       b="ABY";
      |         ^~~~~
combo.cpp:37:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   37 |       b="ABX";
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...