Submission #252564

#TimeUsernameProblemLanguageResultExecution timeMemory
252564ChrisTCombo (IOI18_combo)C++17
100 / 100
40 ms672 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence (int n) { string ret; char fi; if (press("XY")) { ret += (fi = press("X") ? 'X' : 'Y'); } else { ret += (fi = press("A") ? 'A' : 'B'); } char a = 'A' + (fi == 'A'); char b = fi <= 'B' ? 'X' : 'B'; char c = fi <= 'X' ? 'Y' : 'X'; for (int i = 2; i < n; i++) { int go = press(ret + a + ret + b + a + ret + b + b + ret + b + c); if (go == i+1) ret += b; else if (go == i) ret += a; else ret += c; } if (ret.length() < n) { int go = press(ret + a + ret + b); if (go == n) { ret += press(ret + a) == n ? a : b; } else { ret += c; } } return ret; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |  if (ret.length() < n) {
      |      ~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...